Wednesday 12 September 2012

calculate height and widht of rectangular

#include<iostream.h>
using namespace std;

class rect{
int left;
int right;
int top;
int bottom;

public:

rect(){
left=0;
right=0;
top=0;
bottom=0;
}

void widht(int w,int x){
int wid;
left=w;
right=x;
wid=right-left;
cout<<wid;
}

void height(int y,int z){
int hei;
top=y;
bottom=z;
hei=bottom-top;
cout<<hei;
}
};
void main(){
clrscr();
rect s1;
int w,x,y,z;
cout<<"\nenter your left side :";
cin>>w;
cout<<"\nenter your right side :";
cin>>x;
cout<<"\nenter your top side :";
cin>>y;
cout<<"\nenter you bootom side :";
cin>>z;

cout<<"\n width :";
s1.widht(w,x);

cout<<"\n height :";
s1.height(y,z);


}

No comments:

Post a Comment