Dr. A.P.J. Abdul Kalam Technical University, Lucknow
KCS101 / KCS201 Programming for Problem Solving - Using C Language
Lab Exercises
4. Write a program that accepts the temperature in Centigrade and converts into Fahrenheit using the formula C / 5 = (F - 32) / 9.
/*
File: Prgrm04.c
Author: Aditya Saini
Date: Sept 17, 2019
Description: Program to convert Centigrade into Fahrenheit.
*/
#include <stdio.h>
int main (void)
{
float centigrade;
float fahrenheit;
//Input temperature in centigrade.
printf ("Input temperature in Centigrade: ");
scanf ("%f", ¢igrade);
float fahrenheit;
//Input temperature in centigrade.
printf ("Input temperature in Centigrade: ");
scanf ("%f", ¢igrade);
//Calculate temperature in fahrenheit.
fahrenheit = centigrade * 9.0 / 5.0 + 32.0;
//Output the result. 248 is used for degree symbol (°).
printf ("%.2f%cC = %.2f%cF", centigrade, 248, fahrenheit, 248);
//Output the result. 248 is used for degree symbol (°).
printf ("%.2f%cC = %.2f%cF", centigrade, 248, fahrenheit, 248);
};
Output
Input temperature in Centigrade: 36.89
36.89°C = 98.40°F
No comments:
Post a Comment
Please do not post spam links.