7. Program that allows the user to enter a floating-point number representing degrees Celsius, and then displays the corresponding degrees Fahrenheit.
Chapter 2:
C++ Programming Basics
Programming Exercise
Problem # 7:
You can convert temperature from degrees Celsius to degrees Fahrenheit by multiplying by 9/5 and adding 32. Write a program that allows the user to enter a floating-point number representing degrees Celsius, and then displays the corresponding degrees Fahrenheit.
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
float Cel, Faren;
cout<<"Enter temperature in degree celsius:";
cin>>Cel;
Faren=(Cel*9/5)+32;
cout<<"Temperature in Farenheit: "<<Faren;
return 0;
}
#include<conio.h>
using namespace std;
int main()
{
float Cel, Faren;
cout<<"Enter temperature in degree celsius:";
cin>>Cel;
Faren=(Cel*9/5)+32;
cout<<"Temperature in Farenheit: "<<Faren;
return 0;
}
Let me know in the comment section if you have any question.
Previous Post:
6. Program that allows the user to enter an amount in dollars, and the displays this value converted to other monetary units.
Comments
Post a Comment