Back To C Flow of Control Index
//program to convert fahrenheit temp to celsius and vice versa using if-else statement #include
#include
void main() { int choice; float temp,conv; clrscr(); printf("\n1. fahrenheit to celsius"); printf("\n2. celsius to fahrenheit"); printf("\nenter your choice 1,2"); scanf("%d",&choice); if(choice==1) { printf("\nenter temperature in fahrenheit"); scanf("%f",&temp); conv=(temp-32)/1.8; printf("\ntemperature in celsius is %f",conv); } else { printf("\nEnter temperature in celsius "); scanf("%f",&temp); conv=(1.8*temp)+32; printf("\ntemperature in fahrenheit is %f",conv); } getch(); }