ITC LAB Assignment # 2 Faizan Asad P16-6073 CS (B)

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

ITC LAB Assignment # 2

Faizan Asad
P16-6073
CS(B)

Question No # 1
#include <iostream>
using namespace std;
int main()
{
int x, a, b, c, d, e,f, sum;
cout << " Enter a six digit number << endl;
cin >> x;
if (x>=100000 && x<=999999)
{
a= x/ 100000;
b=x / 10000 % 10;
c= x / 1000 % 10;
d= x/100 % 10;
e= x/10 % 10;
f= x%10;
sum = a+b+c+d+e+f;
cout << a<< " + " << b<< " + " << c<< " + " << d<< " + " <<e <<" +
"<<f <<" = "<< sum <<endl;
}
else
cout <<" Enter a six digit number." <<endl;
}

Question No # 2

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float a,b,c,L,M,S,T,U ,y,n1,n2,n3,n4,X;
cout<<" Enter n1"<<endl;
cin>>n1;
cout<<" Enter n2"<<endl;
cin>>n2;
cout<<" Enter n3"<<endl;
cin>>n3;
cout<<" Enter n4"<<endl;
cin>>n4;
a=2*pow(n1,3)+3*pow(n1,2)+1*pow(n1,0.5);
b=a/
(5*pow(n1,3));

S=2*pow(n2,3)+3*pow(n2,2)+1*pow(n2,0.5);
c=S/
(5*pow(n2,3));
T=2*pow(n3,3)+3*pow(n3,2)+1*pow(n3,0.5);
L=T/
(5*pow(n3,3));
U=2*pow(n4,3)+3*pow(n4,2)+1*pow(n4,0.5);
M=U/
(5*pow(n4,3));
y=b+c+L+M;
X=1*pow(y,0.5) ;
cout<<" x = " <<X <<endl;
}

You might also like