What is difference b/w Functional Oriented and Object Oriented Desgin?

First we must have to know how many things involved in program

1) Data (Which stores state of program, usually variables)

2) Function(Which process on data)

If we are not getting desired result/output in our system this could be happen due to two possibilities 

1) Algorithm problem

2) Problem in data

If we have logical problem then we know in which function we have to change but if problem in our data we don’t know which functions will be effected if we changed.

In Functional Oriented.

  1. Function knows which data I am using but data does not know which functions are using me(data)
  2. Functions and data are not combine together
  3. So data is globalized (not localized)

While in Object Oriented (OO)

  1. Function(method) knows which data I am using and data also know which functions are using me(data). In OO data is localized to this class.
  2. Functions and  data combine together
  3. So data is localized(not globalized)

Q) Why we prefer Object Oriented Over Functional Oriented?

In OO our maintenance is very easy due to data localization in a class.

Mostly 2/3 time is spend in software maintenance.

 

PHP Interview questions

  1. How would you find out if a string contains another string in PHP?
  2. Find time taken by any loop?
  3. What is associative array?
  4. What is cURL and why we use cURL?
  5. Is it possible to draw image? if yes than how?
    <img src=”image.php”>
  6. Count number of words in paragraph
  7. Count speciifc number of word in paragraph
  8. How to make global variable?
  9. Upload data is not uploading due to maxsize, tell these factors?
  10. How would you find out if a string contains another string in PHP?
  11. which oop concept is not in PHP?
  12. Print your name with out using loop?
  13. Diff b/w require and include?
  14. Diff b/w unlink and unset?
  15. What is the result of following statements$a = 5; // answer
    echo $a; 5
    echo “result is $a”; result is 5
    echo ‘result is $a’;

Boost your C – Language by implementing these Programs :

courtesy by Arsalan Shahid:
1) Allon ———- Turns all the lights of the keyboard one by one.
2) Ascendin ——- Input 3 numbers and arrange them in ascending order.
3) Ayaz ———– The beginning of every program.
4) Big&sma ——– Ask the total number of inputs and then tells the biggest and the smallest number.
5) Bitpos ——— shows how computer understand a number OR sort of a binary conversion.
6) Calculator —– Calculator.
7) Capslck ——– Toggles the capslock.
8) Diamond ——– Text Diamond.
9) Discount ——- Tells the discount on the original price.
10) Keystat ——– Tells the keystatus of the keyboard.
11) keystat1 ——- Tells the keystatus of the keyboard either on or off.
12) Newton ——— Newton raphson method.
13) Oddeven ——– Odd and Even series which depends on the initial limit.
14) Oddeven1 ——- Prints odd or even series, what ever is our choice.
15) Prime ———- Prints prime numbers with in the given limits.
16) Pyramid ——– A right angeled triangle with square.
17) Pyramid1 ——- A right angeled triangle with a line of same numbers.
18) Pyramid2 ——- A right angeled triangle with a line of sequence of numbers.
19) Pyramid3 ——- A non-true equilateral triangle.
20) Pyramid4 ——- A true equilateral triangle.
21) Pyramid5 ——- Pascal’s triangle.
22) Screen ——— Saves anything on the screen.
23) Smallest ——- Takes 3 numbers input and tells the smallest number.
24) Sum ———— Takes ten numbers inputs and tells sum and average of these numbers.
25) Sum1 ———– Takes ten numbers inputs and tells sum and average of these numbers. Also tells the numbers.
26) Tafreeh ——– Toggles the capslock and preparing the system.
27) Trapezoi ——- Trapezoidal Method.
28) Func ———– Function’s first program.
29) wordcnt ——– Counts the entered characters and words.
30) matrix ——— Multiplication of 2 matrices.
31) magic ———- Magic (box) square.
32) string ——— Inputs a string sentence and prints the string on seperate lines where ever a space is placed.
33) factor ——— Tells all the possible factors of an inputed number.
34) quadequa ******* Randomly generates quadratic equation (factorizable, completing the squares & quadratic formula) separately.
35) asign2 ********* Omits the unwanted words from the given sentence.
36) struct ——— Struct first program.
37) structa ——– Struct program with array.
37) fwrite ——— File write first program.
38) fread ———- File read first program.
39) Faboni ——— Generate Fabonaic series upto the given number of members.
40) Faboni1 ——– Generate Fabonaci series upto the given limit.
41) problem01 ——- Scans a number either it is a prime number or not.
42) problem02 ——- Prints a series of first 100 prime numbers.
43) problem03 ——- A right angeled triangle with a line of sequence of numbers.
44) problem04 ——- Prints a text based hollow square.
45) problem05 ——- Input a four digit number and add its individual digits.
46) problem06 ——- Input a four digit number and reverse it.
47) problem07 ——- Decimal to binary conversion.
48) problem08 ——- Binary to decimal conversion.
49) problem09 ——- Prints text based union jack of the given dimension.
50) problem10 ——- Prints text based equilateral triangle.
51) problem11 ——- Prints different types of triangles.
52) problem12 ——- Prints your name at the four corners of the screen.
53) problem13 ——- Prints the factorial of the given number.
52) problem14 ——- Tells the result of any number with its power without using “pow”.
53) problem15 ——- Tells the mulplication result of two numbers without using “*”.
54) problem16 ——- Function thats returns the square of a number.
55) problem17 ——- L.C.M calculator.
56) problem18 ——- G.C.D calculator.
57) problem19 ——- Generate Fabonaic series upto the given number of members.
58) problem20 ——- Functions of detecting biggest and smallest number.
59) problem21 ——- Prints the factors of the given number.
60) problem22 ——- Tells the difference between two times in the form of hr:min:sec.
61) problem23 ——- Calculates GPA of any subject you want by giving it your marks and the total marks.
62) problem24 ——- Inputs an array of numbers and tells the average,most repeated,smallest and biggest number.
63) problem25 ——- Input five numbers and display a histogram according to the values.
64) problem26 ——- Inputs a string and redisplay it with an additional space between each character.
65) problem27 ——- Inputs an array and sort it in ascending order.
66) problem28 ——- Inputs an array and then a key then find the position of the key in that array.
67) problem29 ——- Matrix Calulator (input two matrices and prints the desired output).
68) problem30 ——- Inputs a number and tells the roman equivalent of that number.
69) problem31 ——- Inputs two sets and tells their union.
70) problem32 ——- Inputs two sets and tells their intersection.
71) problem33 ——- Inputs a number and tells it in words within limit of 0 to 9999.
77) prime1 ——— Inputs two numbers and prints the series of prime numbers between the corresponding numbers (wahaj prac.).
78) pract ********** Inputs an 2-D array and prints the greatest, least and most repeated number (my pract).
79) namesort ——- Inputs ten names and sort it in ascending order.
80) bublsort ——- Sorting by bubble sort algorithm.
81) selsort ——– Sorting by selection sort algorithm.
82) inssort ——– Sorting by insertion sort algorithm.
83) quiksort ——- Sorting by quick sort algorithm.
84) singlink ——- Manages a link list (adding,searching and traversing) in ascending order.
85) postfix ——– Inputs an infix expression and convert it into postfix form and evaluate it.
86) fctorial ——- Calculates the factorial of the given number recurrsively.
87) power ———- Calculates the value of a number with its exponent recurrsively.
88) gcd ———— Calculates the gcd of two numbers recurrsively.
89) gpacal ********* Calculates the gp of each subject & cumulative, very informatively, within a particular environment.
90) intrpts ——– Uses of different interrupts (like printing, time, date, memory, cursor etc).
91) pnt2func ——- First program to use a pointer to a function.
92) qsort ———- Usage of library function-qsort.
93) diffsort ——- Sorts a database according to user needs.
94) ownisr ——— It writes my own interrupt handler (service routine) on the 0x1c of interrupt vector table.
95) impfiles ——- It uses different important files to write data on different output devices.
96) spotline ——- It uses graphics of ‘C’ and draws line or spot with key movements.
97) fileread ——- It reads any given file upto 3000 characters.
98) crack ———- It cracks the folder guard and let u be the administartor.
99) trpllink ——- Manages a link list (adding,searching and traversing) in ascending, descending and original order.
100) dbllink ******* Manages a link list (adding,searching and traversing) in ascending, descending order.
101) bmp ———– Loads a bmp image in dos using 4 different methods.
102) 16col ——— Loads a 16 color bmp image in dos of any size.
103) edge_det —— Detects edges in a black & white bmp image and hollow the original image and saves back to file.
104) edge01 ——– Detects edges in a black & white bmp image and bordered the original image with red color.
105) edge02 ********
106) del_char —— Deletes a specified character from a whole file.
107) del_word ****** Deletes a specified word (string) from a whole file.
108) filecopy —— Duplicates a file.
109) binary ——– Searching by binary search algorithm.
110) fdiff ——— Infinite differences calulator.
111) fdiff01 ——- Infinite differences calulator (prints vertically inside a table).
112) bblsort ——- Bubble sorting without changing original array (with pointers).
113) inssort ——- Insertion sorting without changing original array (with pointers).
114) selsort ——- Selection sorting without changing original array (with pointers).
115) link01 ——– Link list with proper functions.
116) strstr ——– Extended version of strstr that identifies all of the occurrences of substring.
117) missing ——- Finds missing values in the infinite difference series.
118) error ——— Error correction in infinite difference series.
119) bisect ——– Bisection method of finding roots of a equation.
120) interpol —— Interpolation method of finding roots of a equation.
121) swap ———— Swaps any two variables.

check the string for palindrome

#include#includeusing namespace std; 
// the namespace for cout<< & such functions 
int main() 

char strn[80]; 
cout<<“Enter the string: “;
cin.getline(strn,80); 
int len=strlen(strn);
 bool flag=true; // create a Boolean value, “flag” to be used in our loop
 for(int c=0;c!=len/2;c++) // do a loop from 0 to half the length of the string 
{
        if(strn[c]!=strn[len-c-1]) // check the characters match        
       { 
                  flag=false; // if they don’t set the indicator to false 
                   break; // if it is not a palindrome, exit the for loop 
        } 

 // if flag is true cout “Palindrome” otherwise output “Not Palindrome” 
 if(flag)
{
 cout<<“Palindrome”; 

else 
{
 cout<<“Not Palindrome”; 

 cin.get(); 
return 0;

 }

Association, Aggregation, Composition, Abstraction, Generalization, Realization, Dependency

These terms signify the relationships between classes. These are the building blocks of object oriented programming and very basic stuff. But still for some, these terms look like Latin and Greek. Just wanted to refresh these terms and explain in simpler terms.

Association:
Association is a relationship between two objects. In other words, association defines the multiplicity between objects. You may be aware of one-to-one, one-to-many, many-to-one, many-to-many all these words define an association between objects. Aggregation is a special form of association. Composition is a special form of aggregation.
Example: A Student and a Faculty are having an association.

Aggregation:
Aggregation is a special case of association. A directional association between objects. When an object ‘has-a’ another object, then you have got an aggregation between them. Direction between them specified which object contains the other object. Aggregation is also called a “Has-a” relationship.

Composition:
Composition is a special case of aggregation. In a more specific manner, a restricted aggregation is called composition. When an object contains the other object, if the contained object cannot exist without the existence of container object, then it is called composition.
Example: A class contains students. A student cannot exist without a class. There exists composition between class and students.

Difference between aggregation and composition?
Composition is more restrictive. When there is a composition between two objects, the composed object cannot exist without the other object. This restriction is not there in aggregation. Though one object can contain the other object, there is no condition that the composed object must exist. The existence of the composed object is entirely optional. In both aggregation and composition, direction is must. The direction specifies, which object contains the other object.
Example: A Library contains students and books. Relationship between library and student is aggregation. Relationship between library and book is composition. A student can exist without a library and therefore it is aggregation. A book cannot exist without a library and therefore its a composition. For easy understanding I am picking this example. Don’t go deeper into example and justify relationships!

Abstraction:
Abstraction is specifying the framework and hiding the implementation level information. Concreteness will be built on top of the abstraction. It gives you a blueprint to follow to while implementing the details. Abstraction reduces the complexity by hiding low level details.
Example: A wire frame model of a car.

Generalization:
Generalization uses a “is-a” relationship from a specialization to the generalization class. Common structure and behaviour are used from the specializtion to the generalized class. At a very broader level you can understand this as inheritance. Why I take the term inheritance is, you can relate this term very well. Generalization is also called a “Is-a” relationship.
Example: Consider there exists a class named Person. A student is a person. A faculty is a person. Therefore here the relationship between student and person, similarly faculty and person is generalization.

Realization:
Realization is a relationship between the blueprint class and the object containing its respective implementation level details. This object is said to realize the blueprint class. In other words, you can understand this as the relationship between the interface and the implementing class.
Example: A particular model of a car ‘GTB Fiorano’ that implements the blueprint of a car realizes the abstraction.

Dependency:
Change in structure or behaviour of a class affects the other related class, then there is a dependency between those two classes. It need not be the same vice-versa. When one class contains the other class it this happens.
Example: Relationship between shape and circle is dependency.