Code Competitions

Coding competition

Sunday, 12 May 2013

Program to convert celcius to farnehite or vice verse

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
    float c,f;
    int ch;
    clrscr();
    printf("\n 1. convert fahrenheit to celcius");
    printf("\n 2. convert centigrade to fahrenheit");
    printf("\n 3. exit\n");
    scanf("%d",&ch);
    switch(ch)
    {
        case 1:
        {
            printf("enter temp in fahrenheit");
            scanf("%f",&f);
            c=5.0/9*(f-32);
            printf("temp in centigrade %f",c);
            break;
        }
        case 2:
        {
            printf("enter temp in centigrade");
            scanf("%f",&c);
            f=((9.0*c)/5)+32;
            printf("temp in  fahrenheit %f",f);
            break;
        }
        case 3:
        {
            exit(0);
        }
    }
    getche();
}

No comments:

Post a Comment