Q. Perimeter of a rectangle by passing argument ?
THE OUTPUT WOULD BE
#include<iostream.h>
#include<conio.h>
class A
{ int l,b,p;
public:
void B( int x,int y)
{ l=x;
b=y;
}
void C();
};
void A::C()
{ p=2*(l+b);
cout<<"Perimeter of Rectangle="<<p;
}
void main()
{ clrscr();
A obj;
obj.B(2,4);
obj.C();
getch();
}
No comments:
Post a Comment