|
The following program illustrates the usage
and application of cin:
//Program 1.6
//This program demonstrates the usage
#include<iostream.h>
void main()
{
float fTemp;
float fCels;
cout<<"Enter the temperature in farenheit: ";
cin>>fTemp;
fCels = (fTemp - 32) * 5/9;
cout<<"The equivalent temperature in celsius is: "<<fCels<<endl;
}
The statement:
cin>>fTemp;
in the program causes the program to wait for the user to
enter a value. This value is stored in the fTemp variable.
In Program 1.6 if the user enters 64, then the output of the
program is:
The equivalent temperature in celsius is: 17.7778 |