#include<iostream>
using namespace std;
#include<conio.h>
#define pi 3.142
void area(int);
void area(float);
void area(float, float);
void main()
{
int ch,s;
float l,b,r;
do
{
cout<<"-----MENU----- \n";
cout<<"1. Square \n";
cout<<"2. Circle \n";
cout<<"3. Rectangle \n";
cout<<"4. Exit \n\n";
cout<<"Make a choice: ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter side of Square: ";
cin>>s;
area(s);
break;
case 2:
cout<<"Enter radius of Circle: ";
cin>>r;
area(r);
break;
case 3:
cout<<"Enter length of Rectangle: ";
cin>>l;
cout<<"Enter breadth of Rectangle: ";
cin>>b;
area(l,b);
break;
case 4:
exit(0);
default:
cout<<"Invalid Choice \n";
break;
}
}
while(ch!=4);
getch();
}
void area(int s)
{
int area;
area=s*s;
cout<<"The Area of Square= "<<area<<"\n";
}
void area(float r)
{
float area;
area=pi*r*r;
cout<<"The Area of Circle= "<<area<<"\n";
}
void area(float l, float b)
{
float area;
area=l*b;
cout<<"The Area of Rectangle= "<<area<<"\n";
}
using namespace std;
#include<conio.h>
#define pi 3.142
void area(int);
void area(float);
void area(float, float);
void main()
{
int ch,s;
float l,b,r;
do
{
cout<<"-----MENU----- \n";
cout<<"1. Square \n";
cout<<"2. Circle \n";
cout<<"3. Rectangle \n";
cout<<"4. Exit \n\n";
cout<<"Make a choice: ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter side of Square: ";
cin>>s;
area(s);
break;
case 2:
cout<<"Enter radius of Circle: ";
cin>>r;
area(r);
break;
case 3:
cout<<"Enter length of Rectangle: ";
cin>>l;
cout<<"Enter breadth of Rectangle: ";
cin>>b;
area(l,b);
break;
case 4:
exit(0);
default:
cout<<"Invalid Choice \n";
break;
}
}
while(ch!=4);
getch();
}
void area(int s)
{
int area;
area=s*s;
cout<<"The Area of Square= "<<area<<"\n";
}
void area(float r)
{
float area;
area=pi*r*r;
cout<<"The Area of Circle= "<<area<<"\n";
}
void area(float l, float b)
{
float area;
area=l*b;
cout<<"The Area of Rectangle= "<<area<<"\n";
}
1)
ReplyDelete#include
#include
using namespace std;
class complex
{
public:
int real,img, a,b,c;
public:
complex()
{
cout<<"enter realpart";
cin>>a;
cout<<"enter imaginary part";
cin>>b;
}
complex(int x,int y)
{
real= x;
img=y;
}
complex operator-(complex c1)
{
complex temp(0,0);
temp.real=real-c1.real;
if(img
#include
using namespace std;
class complex
{
public:
int real,img, a,b,c;
public:
complex()
{
cout<<"enter realpart";
cin>>a;
cout<<"enter imaginary part";
cin>>b;
}
complex(int x,int y)
{
real= x;
img=y;
}
complex operator+(complex c1)
{
complex temp(0,0);
temp.real=real+c1.real;
temp.img=img+c1.img;
return temp;
}
};
/*void display()
{
cout<
#include
using namespace std;
class complex
{
public:
int real,img, a,b,c;
public:
complex()
{
cout<<"enter realpart";
cin>>a;
cout<<"enter imaginary part";
cin>>b;
}
complex(int x,int y)
{
real= x;
img=y;
}
/*friend complex operator+(complex c1, complex c2)
{
complex temp(0,0);
temp.real=c1.real+c2.real;
temp.img=c1.img+c2.img;
return(temp);
}*/
/*
friend complex operator+(complex c1, int z)
{
complex temp(0,0);
temp.real=c1.real+z;
return (temp);
}*/
/*friend complex operator-(complex c1, complex c2)
{
complex temp(0,0);
temp.real=c1.real-c2.real;
if(c1.img<c2.img)
{
temp.img=c1.img;
}
else
{
temp.img=c2.img;
}
return(temp);
}*/
/*void display()
{
cout<<real<<"+"<<img<<"i"<<"\n";
}*/
void displaysub()
{
cout<<real<<"-"<<img<<"i"<<"\n";
}
complex operator-()
{
/*real=-real;
img=-img;*/
complex temp(0,0);
temp.real=-real;
temp.img=-img;
return temp;
}
};
/*complex complex::operator +(complex c1, complex c2)
{
complex temp(0,0);
temp.real=c1.real+c2.real;
return(temp);
}
*/
void main()
{
complex c1,c2,add(0,0),c3(c1.a,c1.b),c4(c2.a,c2.b),sub(0,0),subu();
int f,u,i,o;
/*add=c3+10;*/
/*sub=c3-c4;*/
c3=-c3;
/*add.display();*/
/*sub.displaysub();*/
c3.displaysub();
getch();
}