C++ List of Experiment
C++ List of Experiment
WRITE A PROGRAM TO ILLUSTRATE CLASS AND OBJECT WRITE A PROGRAM TO ILLUSTRATE ARITHMETIC EXPRESSION WAP TO ILLUSTRATE ARRAY WAP TO ILLUSTRATE FUNCTION WAP TO ILLUSTRATE CONSTRUCTOR WAP TO ILLUSTRATE CONSTRUCTOR WITH PARAMETER WAP TO ILLUSTRATE INHERITANCE WAP TO ILLUSTRATE FUNCTION OVERLOADING
/*write a program to illustrate class and object*/ #include<iostream.h> #include<conio.h> class deepak { private: int a,b,c; public: void getdata(); void showdata(); void sum(); }; void deepak::getdata() { cout<<"enter tha a,b"; cin>>a>>b; } void deepak::showdata() { cout<<"a is"<<a<<endl; cout<<"b is "<<b<<endl; } void deepak::sum() { c=a+b; cout<<"the sum is"<<c; } void main() { clrscr(); deepak d; d.getdata(); d.showdata(); d.sum();
getch(); }
Output
/*write a program to illustrate arithmetic expression*/ #include<iostream.h> #include<conio.h> void main() { clrscr(); int a,b,result; float div_result; char choice; cout<<"enter a and b"; cin>>a>>b; cout<<"enter the operation you want to perform"<<endl; cout<<"+ for add"<<endl<<"- for substraction"<<endl; cout<<"* for multiplication"<<endl<<"/ for division"<<endl<<"% for reminder"<<endl; cin>>choice; switch(choice) { case '+': result=a+b; cout<<"the sum is "<<result; break; case '-': result=a-b; cout<<"the substraction is "<<result; break; case '*': result=a*b; cout<<"the multiplication is "<<result; break; case '/': div_result=(float)a/b; cout<<"the division is "<<div_result; break; case '%':
result=a%b; cout<<"the reminder is "<<result; break; default: cout<<"wrong input"; break; } getch(); }
Output
#include<iostream.h> #include<conio.h> void main() { clrscr(); int a[10],i,sum=0; cout<<"enter the ten numbers"; for(i=0;i<=9;i++) { cin>>a[i]; } for(i=0;i<=9;i++) { cout<<a[i]<<endl; sum=sum+a[i]; } cout<<"the sum of all these ten numbers are:"<<endl<<sum; getch(); }
Output:
/* WAP TO ILLUSTRATE FUNCTION*/ #include<iostream.h> #include<conio.h> void sum(int a, int b); //function declartion
void main() { clrscr(); int x,y; cout<<"enter the x and y"; cin>>x>>y; sum(x,y); //function call getch(); } void sum(int a, int b) //function defination { int c; c=a+b; cout<<"the sum is "<<c<<endl; }
Output:
/*WAP TO ILLUSTRATE CONSTRUCTOR*/ #include<iostream.h> #include<conio.h> class sirt { public: sirt() { cout<<"my name is deepak"; } }; void main() { clrscr(); sirt s; getch(); }
Output:
/*WAP TO ILLUSTRATE CONSTRUCTOR WITH PARAMETER*/ #include<iostream.h> #include<conio.h> class sirt1 { public: sirt1(int x, int y) { int z; z=x+y; cout<<"the sum is "<<endl<<z; } }; void main() { clrscr(); sirt1 s(20,30); getch(); }
Output:
/*WAP TO ILLUSTRATE INHERITANCE */ #include<iostream.h> #include<conio.h> class sirt { protected: int x,y; public: void getdata(); void showdata(); }; class sirt1: public sirt { private: int z; public : void sum(); }; void sirt::getdata() { cout<<"enter x"; cin>>x; cout<<"enter y"; cin>>y; } void sirt::showdata() { cout<<"the x is"<<x<<endl; cout<<"the y is "<<y<<endl; } void sirt1::sum() { z=x+y; cout<<"the sum is"<<z<<endl; }
OUTPUT:
/*WAP TO ILLUSTRATE FUNCTION OVERLOADING */ #include<iostream.h> #include<conio.h> class sirt { private: int x,y,z; public: void getdata(); void sum(); void sum(int a,int y); void sum(int i,int j, int k); }; void sirt::getdata() { cout<<"enter x"; cin>>x; cout<<"enter y"; cin>>y; } void sirt::sum() { int z; z=x+y; cout<<"the sum is "<<z<<endl; } void sirt::sum(int a,int b) { int c; c=a+b; cout<<"the sum is "<<c<<endl; } void sirt::sum(int i, int j, int k)
{ int l; l=i+j+k; cout<<"the sum is"<<l<<endl; } void main() { clrscr(); sirt s; s.getdata(); s.sum(); s.sum(10,20); s.sum(50,100,150); getch(); }
OUTPUT:
SQL
SQL> insert into student values('rahul','0521102',1212121); 1 row created. SQL> select * from student;
SQL> select * from student; STUDENT_NAME STUDENT_ID ------------------------------------deepak 0521101 kamlesh 0521102 Syntax of delete particular rows: STUDENT_PDONE -- ------------11111111 1212121
SQL> delete from student; 2 rows deleted. SQL> select * from student; no rows selected