Let us write a program to convert a temperature given in Celsius to Fahrenheit - The formula for conversion is
"f = 1.8C + 32"
/* This program converts a Celsius temperature to Fahrenheit */
# include"stdio.h"
main ( )
{
float fahrenheit, celsius;
scanf(“%f”, & celsius);
fahrenhit = 1.8*celsius + 32.0;
printf (“fahrenheit = % f\n”, fahrenheit);
} /* End of main */
Explaination
Note in the above program after # include we have defined the main function. If the state- ment. float fahrenheit, celsius; is observed we see that
This is a declaration which informs the compiler that fahrenheit and celsius are variable names in which floating point number will be stored. By floating point we mean a number with a fractional part.
The statement scanf(“%f”, & celsius) is a command to read a floating point number and store it in variable name celsius. The format string %f indicates that floating point number is to be read. The next statement is an arithmetic statement contents of celsius is multiplied by 1.8 and added to 32.0 and stored in fahrenheit. The number 32 is written with a decimal point to indicate that it is a floating point number. The last statement is to print the answer.
TABLE OF CONTENTS
...... ATM NETWORK ......... | ... COMPUTER NETWORK.. |
DATA COMMUNICATION | ..... NETWORK MANAGEMENT |
..NETWORK SECURITY | |
.. ISDN |
SQL/DBMS |
MORE TO COME... |
C Program to convert a temperature given in Celsius to Fahrenheit
·
Labels: C
disable right
Labels
- ATM NETWORK (13)
- C (44)
- COMPUTER NETWORK (38)
- DATA COMMUNICATION (24)
- DBMS/SQL (30)
- DOWNLOAD E BOOKS (1)
- HTML (1)
- ISDN (4)
- NETWORK MANAGEMENT (27)
- NETWORK SECURITY (11)
- UML (6)
- WEB ENGG. (17)
About Me
- prince kumar
- bhopal, M.P., India