SlideServe
Menu
Préférences
© SlideServe · v2026

LAB WORK

alexis-chen avatar
9 diapositives · 247 Views · Nov 13, 2014

This document presents solutions to four C++ programming tasks, which include converting degrees to radians and vice versa, performing basic arithmetic operations (addition, subtraction, multiplication, and division) on two user-provided integers, and converting Celsius temperatures to Fahrenheit. Each solution includes the necessary code snippets and explanations to help students and beginners understand fundamental programming concepts in C++. The programs are straightforward and designed for educational purposes, assisting learners in grasping C++ syntax and functionality.

LAB WORK - slide 1
01 / 9LAB WORK
1 / 17

Télécharger la présentation

LAB WORK
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  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; }