/*Program.c*/
#include<stdio.h>
int main()
{
int a;
float C,F;
printf("What is your input type?\n");
printf("1-Celsius\n");
printf("2-Farenheit\n");
printf("Enter number of your preference: ");
scanf("%d",&a);
switch(a)
{ case 1:
printf("Enter your temperature in Celsius: ");
scanf("%f",&C);
F=(9*C/5)+32;
printf("Temperature reading: %.2f",F);
printf(" F\n");
break;
case 2:
printf("Enter your temperature in Farenheit: ");
scanf("%f",&F);
C=5*(F-32)/9;C=5*(F-32)/9;
printf("Temperature reading: %.2f",C);
printf(" C\n");
break;
default:
printf("STOP! Wrong input!\n");
break;
}
return 0;
}
This is a simple program which chage a Celsius reading to Farenheit and Farenheit reading toa celsius reading....
This is working!!!But I want to chage the input method....
here u want to select input method whether it is celsius or farenheit by typing "1" or "2". But I want to chage it...I want to input "f" to select farenheit and "c" to select celsius...How to do it...Please modify this program....I have a little knowledge in C programming..
#include<stdio.h>
int main()
{
int a;
float C,F;
printf("What is your input type?\n");
printf("1-Celsius\n");
printf("2-Farenheit\n");
printf("Enter number of your preference: ");
scanf("%d",&a);
switch(a)
{ case 1:
printf("Enter your temperature in Celsius: ");
scanf("%f",&C);
F=(9*C/5)+32;
printf("Temperature reading: %.2f",F);
printf(" F\n");
break;
case 2:
printf("Enter your temperature in Farenheit: ");
scanf("%f",&F);
C=5*(F-32)/9;C=5*(F-32)/9;
printf("Temperature reading: %.2f",C);
printf(" C\n");
break;
default:
printf("STOP! Wrong input!\n");
break;
}
return 0;
}
This is a simple program which chage a Celsius reading to Farenheit and Farenheit reading toa celsius reading....
This is working!!!But I want to chage the input method....
here u want to select input method whether it is celsius or farenheit by typing "1" or "2". But I want to chage it...I want to input "f" to select farenheit and "c" to select celsius...How to do it...Please modify this program....I have a little knowledge in C programming..