Академический Документы
Профессиональный Документы
Культура Документы
#include<iostream.h> #include<conio.h> class P { public: void show() { cout<<Hello Everybody; } }; void main() { P s; s.show(); getch(); }
Output:
Hello Everybody
Output
Hello 23
Output:
Enter the value for a 5 5 Enter values for a and b 12.12 23.45 Sum is 35
Output:
Enter value for a and b 12 10 Enter the value for code 1 Multi is 120
Output:
Before function call p and q are 10 11 Inside the function p and q are 20 21 After function call p and q are 10 11
Output:
Before function call p and q are 10 11 Inside the function call p and q 20 21 after function call p and q are 20 21
Output:
Enter a number7 number is prime Enter a number6 Number is not prime
Output:
Enter a number 5 Factorial is120
Output:
0 1 1 2 3 5 8 13 21
output:
Enter String:= madam Entered string madam is palindrome
Output:
How many values 5 Enter the elements 6 3 2 1 5 Array is 6 3
Output:
cube is 8 multi is 132
Output:
Sum is: 32 Sum is: 27
output:
sum is 23.
output:
Example of function overloading Cube is 125 sum is 23
Output:
Square is 100
/*Write a program for Static Member Function and Static Data Member*/
#include<iostream.h> #include<conio.h> class P { private: int a; static int count; public: void read(int x) { a=x; count++; } static void getcount() { cout<<"\ncount is "; cout<<count; } }; int P::count; void main() { P x,y,z; clrscr(); P::getcount(); x.read(10); P::getcount(); y.read(20); P::getcount(); z.read(30); P::getcount(); getch(); }
output:
count is 0 count is 1 count is 2 count is 3
output:
Enter rollno and age 1 20 Enter rollno and age 2 20 Enter rollno and age 3 20 Rollno is 1 Age is 20 Rollno is 2 Age is 20 Rollno is 3 Age is 20
Output:
Sum is 21
Output:
multi is 132
Output:
Enter the numbers 12 14 ss is greater14
Output:
a is 12 b is 2
Output:
a is 12 b is 10
Output:
a is 10 b is 12 a is 2 b is 3
Output:
Object created 1 Object created 2 Object created 3 Object created 4 object destroyed 4 object destroyed 3 object destroyed 2
Output:
How many vlaues 5 Enter elements one by one 1 2 3 4 5 1 2 3 4 5 Sum of array is 15
for(i=0;i<3;i++) { for(j=0;j<3;j++) { cout<<arr[i][j]<<"\t"; } cout<<"\n"; } int arr1[3][3]; cout<<"\nEnter values for matrix arr1[][]"; for(i=0;i<3;i++) { for(j=0;j<3;j++) { cin>>arr1[i][j]; } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { cout<<arr1[i][j]<<"\t"; } cout<<"\n"; }
int s[3][3] ; cout<<"\nSum of matrixes are\n"; for(i=0;i<3;i++) { for(j=0;j<3;j++) { s[i][j]=arr[i][j]+arr1[i][j]; cout<<s[i][j]<<"\t"; } cout<<"\n"; } } }; void main() { S p; clrscr(); p.arrs(); getch(); }
Output:
Enter values for matrix arr[][]1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 Enter values for matrix arr1[][]9 8 7 6 5 4 3 2 1 9 8 7 6 5 4 3 2 1 Sum of matrixes are 10 10 10 10 10 10 10 10 10
cout<<"\n"; } cout<<"\nmatrix two\n"; for(i=0;i<2;i++) { for(j=0;j<2;j++) { cout<<"\t"<<b[i][j]; } cout<<"\n"; } cout<<"\nMulti plication of matrix\n"; for(i=0;i<2;i++) { for(j=0;j<2;j++) { cout<<"\t"<<c[i][j]; } cout<<"\n"; } } }; void main() { P o; clrscr(); o.multi(); getch(); }
Output:
Enter the value 1 Enter the value 2 Enter the value 3 Enter the value 4 Enter the value 1 Enter the value 2 Enter the value 3 Enter the value 4
Output:
Hello P Hello S
Output:
This is class A Hello this is class B I inherit class B and A
Output:
This is class A Hello this is class B I inherit two classes
Output:
This is class A Hello this is class B Hello from D This is class A Hello everybody Hi its C
Output:
Hello this is B Hello this is A
Output:
Hello this is B Hello this is A
Output:
Hello this is A Hello this is B Hello this is C Hello this is D
Output:
I derived virtual function for abstract base calss I am another derived class for pure virtual function
o.redisplay(20,30); getch(); }
output:
Hello Multi is 150 Now a and b is 20
30
Output:
a is 10 b is -12 a is -10 b is 12
Output:
a is 12 a is 13 a is 12
Output:
a is 10 b is 11 a is 20 b is 30 a is 30 b is 41
Output:
a is 10 b is 15 a is 20 b is 30 a is 30 b is 45 a is 30 b is 45
Output:
Enter value for a and b10 13.568 ********10 13.57
Output:
enter input Sandeep singh Sandeep singh total no of character 13
Output:
enter name Sandeep name is Sandeep
Output:
name list is aabbcc
Output:
Enter the number 10 a a 12
Output;
marks are 10 20 30 40 50.
Output:
enter the string sandeep sandeep