I am currently doing a lab to demonstrate Standard Input/Output Functions, and I
ID: 3692205 • Letter: I
Question
I am currently doing a lab to demonstrate Standard Input/Output Functions, and I need help creating a C program (please not C++) that performs the following:
Using a loop running on Celsius values starting at 10.0 and decrementing by 5 each iteration to display the following data in exactly the format shown below, where F = 1.8C+32.
Celsius Fahrenheit
+10.0 +50.00
+5.0 +41.00
+0.0 +32.00
-5.0 +23.00
-10.0 +14.00
-15.0 +5.00
-20.0 -4.00
-25.0 -13.00
Explanation / Answer
Solution.cpp
#include<iostream>//header file for input or output functions
using namespace std;//it tells the compiler to links std name space to the compiler
int main()
{//main function which returns integer
float celsius, fahrenheit;
cout<<"celsius and farenheit conversion"<<endl;
cout << " celsius " << "fahrenheit" << endl;//output function is cout
for( celsius=10;celsius>=-25;celsius=celsius-5)
{
fahrenheit = 1.8* celsius + 32;
cout<<" "<<celsius<<" "<<fahrenheit<<endl;
}
return 0;
}
output
celsius and farenheit conversion
celsius fahrenheit
10 50
5 41
0 32
-5 23
-10 14
-15 5
-20 -4
-25 -13
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.