WRITE A PROGRAM FOR PARAMETERIZED CONSTRUCTOR IN C++

 Que- Make a program for parameterized constructor?

#include<iostream>
using namespace std;

class a
{
  public:
  int b,h;
 
public:

a(int w, int t)
{
  b=w;
  h=t;
}

};
int main()
{
  int w, t;
    float area ;
    cout<<"enter breath of triangle :";
   cin>>w;
   cout<<"enter height of triangle :";
   cin>>t;
   a ob (w,t);
   area =0.5*ob.b*ob.h;
cout<<"area of triangle is :"<<area;
   
    return 0;
}

Result:-



Post a Comment

Previous Post Next Post