You are on page 1of 3

Question : Calculat the force that acting on bloc on an incline surface .

#include<iostream>
#include<math.h>
using namespace std;
int main ()
{

double f,F,fx,fy,theta,redain;
cout<< " Enter the force value ";
cin>> f;
theta=60;
redain=theta*(3.14/180);
fx=f*cos(redain);
fy=f*sin(redain);
F=fx+fy;
cout<<"The x force component is="<<fx<<endl;
cout<<"The y force component is="<<fy<<endl;
cout<< "This program to comput the total force
(F)="<<F ;
return 0;

Question : Calculat the result of the follwing equation .z=x^2+y^2

#include<iostream>
#include<math.h>
using namespace std;
int main ()
{
double x,y,z,result;
x = pow(2,2);y=pow(2,2);
z=x+y;
cout<< "This program to comput z=x^2+y^2 which is equal to "<<z;
return 0;
}
Qustion :Write a c++ program to calculate the roots of a quadratic
equation

#include<iostream> #include<iostream>
#include<math.h> #include<math.h>
using namespace std; using namespace std;
int main () int main ()
{ {
double a,b,c,root1,root2; double a,b,c,root1,root2;
cout <<"Enter a value"; cout <<"Enter a value";
cin>>a; cin>>a;
cout <<"Enter b value"; cout <<"Enter b value";
cin>>b; cin>>b;
cout <<"Enter c value"; cout <<"Enter c value";
cin>>c; cin>>c;
if(4*a*c<=b*b) if(4*a*c<=b*b)
{ {
root1=(-b+sqrt(b*b-4*a*c))/(2*a); root1=(-b+sqrt(b*b-4*a*c))/(2*a);
root2=(-b-sqrt(b*b-4*a*c))/(2*a); root2=(-b-sqrt(b*b-4*a*c))/(2*a);
cout<<root1<<endl; cout<<root1<<endl;
cout<<root2<<endl; cout<<root2<<endl;
} }
if(4*a*c>b*b) else
cout<<"maginary"; cout<<"maginary";
return 0; return 0;
} }

You might also like