1 / 9

LAB WORK

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 ;

alexis-chen
Download Presentation

LAB WORK

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LAB WORK Computer Lab. 4-11-2012

  2. Q1/ Write a C++ Program to convert degree to radian? • Q2/Write a C++ program to convert radian to degree?

  3. 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; }

  4. 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; }

  5. 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?

  6. 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; }

  7. Q4/ Write a C++ program to convert Celsius temperature to Fahrenheit? The equation of conversion is : °F=°C  x  9/5 + 32

  8. 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; }

More Related