Program : Convert Fahrenheit to Celsius Temp Take Value from User
#include <iostream.h> // for cout , cin
#include <conio.h> // for getch()
int main()
{
float ft; /* we declare variable ft as float data type can store decimal values also temperature can be come in decimal */
cout << " Enter The Value in Fahrenheit" <<endl; /* <<endl is for new line like \n for new line.*/
cin >> ft; /* Take Value from user and assign to ft variable we can use this variable later in this program and value stored by variable its temporary store ones application close all value reset and again we have to assign value to that variable */
float ct = (ft-32) * 5/9 ;
/* ct variable is define and initialize with a formula that equate the values. Celsius = (F-32)*5/9 . In this we write (ft-32) because its first subtract then its multiply by 5/9. if we write directly ft-32*5/9 its first multiply then its subtract. */
cout << ft << " in celsius = " <<ct <<endl;
/* in this << ft show the value that stored in ft, << "in Celsius = " it just Print The text within double quote & << ct to display equated value that stored in ct variable */
getch();
return 0;
}
Above Program Without Comments
#include <iostream.h>
#include <conio.h>
int main()
{
float ft;
cout << " Enter The Value in Fahrenheit" <<endl;
cin >> ft;
float ct = (ft-32) * 5/9 ;
cout << ft << " in celsius = " <<ct <<endl;
getch();
return 0;
}
OUTPUT
#include <iostream.h> // for cout , cin
#include <conio.h> // for getch()
int main()
{
float ft; /* we declare variable ft as float data type can store decimal values also temperature can be come in decimal */
cout << " Enter The Value in Fahrenheit" <<endl; /* <<endl is for new line like \n for new line.*/
cin >> ft; /* Take Value from user and assign to ft variable we can use this variable later in this program and value stored by variable its temporary store ones application close all value reset and again we have to assign value to that variable */
float ct = (ft-32) * 5/9 ;
/* ct variable is define and initialize with a formula that equate the values. Celsius = (F-32)*5/9 . In this we write (ft-32) because its first subtract then its multiply by 5/9. if we write directly ft-32*5/9 its first multiply then its subtract. */
cout << ft << " in celsius = " <<ct <<endl;
/* in this << ft show the value that stored in ft, << "in Celsius = " it just Print The text within double quote & << ct to display equated value that stored in ct variable */
getch();
return 0;
}
Above Program Without Comments
#include <iostream.h>
#include <conio.h>
int main()
{
float ft;
cout << " Enter The Value in Fahrenheit" <<endl;
cin >> ft;
float ct = (ft-32) * 5/9 ;
cout << ft << " in celsius = " <<ct <<endl;
getch();
return 0;
}
OUTPUT
0 comments:
Post a Comment