//Reverse of the string
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
char a[100];
cout<<"enter any string = ";
cin>>a;
cout<<"\n reverse of given string = ";
cout<<strrev(a);
getch();
}
//Function Overloading
#include<iostream.h>
#include<conio.h>
class ABC
{
private:
float a,b,AREA,r;
public:
void area(float x,float y)
{
AREA=x*y;
cout<<"\nAREA OF RECTANGLE = ";
cout<<AREA<<”\n”;
}
void area(float r1)
{
AREA=(3.14*r1*r1);
cout<<"\nAREA OF CIRCLE = ";
cout<<AREA<<”\n”;
}
};
void main()
{
clrscr();
ABC ob;
float a,b,r;
cout<<"\nenter the value of hight and width = ";
cin>>a>>b;
ob.area(a,b);
cout<<"\nenter the value of radius of circle";
cin>>r;
ob.area(r);
getch();
}
//Array of object
#include<iostream.h>
#include<conio.h>
struct student
{
int age;
char name[20],branch[20];
};
void main( )
{
int i;
clrscr();
student ob[5];
for(i=0;i<5;i++)
{
cout<<"\nPLEASE ENTER THE AGE OF STUDENT = ";
cin>>ob[i].age;
cout<<"\nPLEASE ENTER THE NAME OF STUDENT = ";
cin>>ob[i].name;
cout<<"\nPLEASE ENTER BRANCH OF STUDENT = ";
cin>>ob[i].branch;
cout<<"\n---------------------------------------------------------------";
}
cout<<"\n\nINFORMATION OF STUDENTS = ";
for(i=0;i<5;i++)
{
cout<<"\n\n("<<(i+1)<<") - "<<OB[I].AGE;
cout<<"\n\n("<<(i+1)<<") - "<<OB[I].NAME;
cout<<"\n\n("<<(i+1)<<") - "<<OB[I].BRANCH;
cout<<"\n-------------------------------------------------------------";
}
getch();
}
//operator overloading
#include<iostream.h>
#include<conio.h>
class nike
{
private:
int r,m;
public:
void in( )
{
cout<<"enter the value of r = ";
cin>>r;
cout<<"\nenter the value of m = ";
cin>>m;
}
void out()
{
cout<<"\n\noutput is = ";
cout<<"\n--------------------------------------";
cout<<"\n\nvalue of r = "<<R;
cout<<"\n\nvalue of m = "<<M;
cout<<"\n";
}
void operator ++()
{
r=r+1;
m=m+1;
}
};
void main( )
{
clrscr();
nike ob;
ob.in();
ob.out();
++ob;
ob.out();
getch();
}
No comments:
Post a Comment