Saturday, August 9, 2014

Program to convert Celsius to Fahrenheit and vice versa

Simple C program to convert Celsius to Fahrenheit and vice versa. If you have any doubts, please comment below.
#include<stdio.h> void main() { int a; float c,f; printf("choose 1 for c and 2 for f"); scanf("%d",&a); if (a==1) { printf("enter in c"); scanf("%f",&c); f=(9.0/5.0)*(c+32); printf("temo in f is %f",f); } if(a==2) { printf("enter in f"); scanf("%f",&f); c=(5.0/9.0)*(f-32); printf("temp in c is %f",c); } }

No comments:

Post a Comment