Friday 8 April 2016

WAP for area using default constructor

#include<iostream.h>
#include<conio.h>
class Area{
  int len,bre;
  public:
Area(){
 len=5;
 bre=6;
}
void getlength(){
 cout<<"
Enter length and breadth ";
 cin>>len>>bre;
}

int areacal()
{
 return(len*bre);
}
void display(int temp)
{
 cout<<"
Area = "<<temp;
}
};


void main(){
  Area a1,a2;
  clrscr();
  int temp;
  cout<<"
For Default ";
  temp=a1.areacal();
  a1.display(temp);
  cout<<"
For Paramerised ";
  a2.getlength();
  temp=a2.areacal();
  a2.display(temp);
  getch();
}

No comments:

Post a Comment