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

Problem 6

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
system(" color F5");
float mass,height, BMI;

cout<<"Enter the mass of your body: ";


cin>>mass;

cout<<"Enter the hight of your body: ";


cin>>height;

BMI=mass/(pow(height,2));

cout<<"the body mass index is: "<<BMI<<endl;

return 0;
}

Problem 7

#include<iostream>
using namespace std;
int main()
{
system(" color F0");
//variable definition
float C,F,K,R;

//input data
cout<<"Enter your tempareture degree in celsius: ";
cin>>C;

//operation
F=9/5*C+32;
//display output
cout<<"the tempareture in fahrenhite = "<<F<<endl;

//operation
K=C+273.15;
//display output
cout<<"the tempareture in kelvin = "<<K<<endl;

//operation
R=1.8*K;
//display output
cout<<"the tempareture in rankine = "<<R<<endl;

return 0;
}
Problem 8

#include<iostream>
using namespace std;
int main()
{
system(" color F0");
float b,h,a;

cout<<"enter the base of a triangle: ";


cin>>b;

cout<<"enter the height of a triangle: ";


cin>>h;

a=0.5*b*h;
cout<<"the area of a triangle = "<<a<<endl;
return 0;
}

Problem 9

#include<iostream>
using namespace std;
int main()
{
double Radius, Diameter, Circumference ,Area;
const double PI=3.14;

cout<<"Enter the Radius of a circle: ";


cin>>Radius;

Diameter=2*Radius;
cout<<"the diameter is = "<<Diameter<<endl;

Circumference=2*PI*Radius;
cout<<"the circumference is = "<<Circumference<<endl;

Area=PI*(pow(Radius,2));
cout<<"the area is = "<<Area<<endl;

return 0;
}
Problem 10

#include<iostream>
using namespace std;
int main()
{
float Force, Area, Radius, AxialStress;
const float PI=3.14;

cout<<"Enter the Force: ";


cin>> Force;

cout<<"enter the radius: ";


cin>> Radius;

Area=PI*(pow(Radius,2));
AxialStress=Force/Area;

cout<<"the axial stress sigma = "<<AxialStress<<endl;

return 0;
}

Problem 11

#include<iostream>
using namespace std;
int main()
{
float R, R1, R2, R3;
cout<<"enter resistances 1: \n";
cin>>R1;

cout<<"enter resistances 2: \n";


cin>>R2;

cout<<"enter resistances 3: \n";


cin>>R3;

R=((1/R1)+(1/R2)+(1/R3));
R=1/R;
cout<<"the equivalent resistance is: "<<R<<endl;

return 0;
}
Problem 12

#include<iostream>
using namespace std;
int main()
{
float a,b,c,X1,X2;

cout<<"Enter a: ";
cin>>a;

cout<<"Enter b: ";
cin>>b;

cout<<"Enter c: ";
cin>>c;

X1=((-b)+(sqrt(pow(b,2))-4*(a*c)))/(2*a);
X2=((-b)-(sqrt(pow(b,2))-4*(a*c)))/(2*a);

cout<<"X1 = "<<X1<<endl;
cout<<"X2 = "<<X2<<endl;

return 0;
}

Problem 13

#include<iostream>
using namespace std;
int main()
{
float n1, n2, sum1, sum2;

cout<<"enter first number: ";


cin>>n1;

cout<<"enter second number: ";


cin>>n2;

cout<<"enter your answer: ";


cin>>sum1;

sum2=n1+n2;
cout<<"the right answer is: "<<sum2<<endl;

cout<<"your answer is "<< sum1 <<" and the right answer is "<< sum2 <<endl;

return 0;
}

You might also like