Saturday 29 April 2023

Exercise 1-To demonstrate the use of data types, simple operators and expressions - 2

 2. Accept temperatures in Fahrenheit (F) and print it in Celsius(C) and Kelvin (K) (Hint: C=5/9(F-

32), K = C + 273.15)

#include<stdio.h>
#include<conio.h>

void main()
{
 float f,c,k;
 clrscr();

 printf("\nFinding fahrenheit tempreture in kelvin and celsius:");
 printf("\nEnter the temp in fahrenheit:");
 scanf("%f",&f);

 c=(5/(float)9)*(f-32);
 printf("\nTemp in celsius:%f celsius",c);

 k=c+273.15;
 printf("\nTemp in Kelvin:%f k",k);

 getch();

}
/*
output:

Finding fahrenheit tempreture in kelvin and celsius:                           
Enter the temp in fahrenheit:123                                               
                                                                               
Temp in celsius:50.555557 celsius                                              
Temp in Kelvin:323.705566 k
*/ 

 


No comments:

Post a Comment

Questions

  Exercise 1 Set A . Apply all the three program development steps for the following examples.  1. Accept dimensions of a cylinder and p...