Professional Documents
Culture Documents
Submitted by-
Name-Arshvir Singh
Ques:1
Roll no.- 101808148
Soln:
#include<iostream> Group- F3
#include<math.h>
class triangle
private :
int l,h;
float a;
public :
a=((pow(3,0.5)*x*x)/4);
cout<<"Area = "<<a;
a=(0.5*y*z);
cout<<"Area = "<<a;
int r=pow((w*w-((e*e)/4)),0.5);
a=0.5*r*e;
cout<<"Area = "<<a;
a=pow((y1*(y1-a1)*(y1-b1)*(y1-c1)),0.5);
cout<<"Area = "<<a;
};
int main()
triangle f;
int n,m,j,k,p,o,u;
float a2,b2,c2,d2;
char r;
cin>>n;
case 1:
cin>>m;
f.area(m);//Area function with one argument is called//
break;
case 2:
cout<<endl<<"Enter hieght and base length of your right angled triangle = ";
cin>>j>>k;
break;
case 3:
cin>>o;
p=o;
cin>>u;
break;
case 4:
cin>>b2;
cin>>c2;
cin>>d2;
a2=(b2+c2+d2)/2;
cin>>r;
//Re-running of program//
switch(r)
{ case 'y':
main();
break;
case 'n':
return 0;
return 0;}
Output:
Ques:2
Soln:
#include<iostream>
class publish
{
public:
char n[30];
int p;
cin.get(n,30);
cin>>p;
};
private:
int page;
public:
cin>>page;
{
cout<<"Pages : "<<page<<endl;
};
private :
int play;
public :
cin>>play;
};
int main()
p[0]->put_data();
return 0;
Output:
Ques:3
Soln:
#include<iostream>
int i;
for(i=1;i<=n;i++)
cout<<" "<<c;
cout<<endl;
int main()
char a;
int b;
int n;
char r;
cout<<"Enter Number of arguments you want to enter : \n1.No argument \n2.1 Argument \n3.2
Arguments \nEnter Your choice : ";
cin>>n;
case 1:
display();
break;
case 2:
cin>>a;
display(a);
break;
case 3:
cin>>a;
cin>>b;
display(a,b);
break;
cin>>r;
case 'y':
main();
break;
case 'n':
return 0;
break;
return 0;
Output:
Ques:4
Soln:
#include<iostream>
class Complex{
private:
float r;
float i;
public:
Complex()//Constructor//
cin>>r>>i;
r=x;
i=y;
void display()
cout<<r<<" + "<<"i"<<i;
{
Complex s(0.0,0.0);
s.i=this->i+c.i;
return s;
};
int main()
Complex c1,c2,c3(0.0,0.0);
c1.display();
cout<<endl;
c2.display();
cout<<endl;
c3=c1.sum(c2);
cout<<endl<<"Sum = ";
c3.display();
return 0;
Output:
Ques:5
Soln:
#include<iostream>
class A
private :
int a;
int b;
public :
A()//Constructor//
{
a=10;
b=15;
a=x;
b=15;
a=y;
b=z;
a=p.a*5;
b=p.b*5;
void display()
};
int main()
A o1;
A o2(5);
o2.display();
A o3(20,25);
o3.display();
A o4(o3);
o4.display();
return 0;
Output: