90 likes | 225 Views
LAB WORK. Computer Lab. 4-11-2012. Q1/ Write a C++ Program to convert degree to radian? Q2/Write a C++ program to convert radian to degree?. Solution Q1 :. # include < iostream.h > #define PI 3.145678 void main() { cout <<"This program is for converting radian to degree"<< endl ;
E N D
LAB WORK Computer Lab. 4-11-2012
Q1/ Write a C++ Program to convert degree to radian? • Q2/Write a C++ program to convert radian to degree?
Solution Q1: #include <iostream.h> #define PI 3.145678 void main() { cout<<"This program is for converting radian to degree"<<endl; double degree,radian; cout<<"Please enter the value of the radian"<<endl; cin>>radian; degree=(radian*180)/PI; cout<<"The value of"<<"("<<radian<<")"<<"in degree is ="<<degree<<endl; }
Solution Q2: #include <iostream.h> #define PI 3.145678 void main() { cout<<"This program is for converting degree to radian"<<endl; double degree,radian; cout<<"Please enter the value of the degree"<<endl; cin>>degree; radian=(degree*180)/PI; cout<<"The value of"<<"("<<degree<<")"<<"in radian is ="<<radian<<endl; }
Q3/ Write a C++ program to perform basic arithmetic operations i.e. addition , subtraction, multiplication and division of two numbers. Numbers are assumed to be integers and will be entered by the user?
Solution Q3 #include <iostream.h> #define PI 3.145678 void main() { cout<<"This program is Performing simple calculations on two variables"<<endl; float x,y; doubleadd,sub,multip,division; cout<<"Please enter the value of X & Y"<<endl; cin>>x>>y; add=x+y; sub=x-y; multip=x*y; division=x/y; cout<<"The addition of X and Y is ="<<" "<<add<<endl; cout<<"The subtraction of X from Y is ="<<" "<<sub<<endl; cout<<"The Multiplication of X and Y is ="<<" "<<multip<<endl; cout<<"The division of X by Y is ="<<" "<<division<<endl; }
Q4/ Write a C++ program to convert Celsius temperature to Fahrenheit? The equation of conversion is : °F=°C x 9/5 + 32
SolutionQ4 #include <iostream.h> #define PI 3.145678 void main() { cout<<"This program is for converting Celsius to Fahrenheit"<<endl; cout<<endl; floatf,c; cout<<"Please Enter the value of Celsius "; cin>>c; cout<<endl; f=((c*9)/5)+32; cout<<"The value of "<<"("<<c<<")"<<"in Fahrenheit ="<<" "<<f<<endl; cout<<endl; }