hi, I’ve got a task home and I have a little problem how can I give a command at which somebody who use this program
can break it at any time he want just by pressing 'E'? I know
that it supposed to be with –while- but I don’t know where to put it
this code supposed just to convert units between fahrenheit to clesius.
thanks. my code is
#include <stdio.h>
int main()
{
float num1,num2;
char unit;
printf("Enter the unit of value (f or c)- end with E\n");
scanf("%c" , &unit);
while(unit=='c' || unit=='f ')
{
printf("Incorrect unit entered.please enter again \n");
scanf("%c" , &unit);
}
if(unit=='c') /*celsius to Fahrenheit*/
{
printf("enter celsius degree\n");
scanf("%f",num1);
num2=9/5*num1+32;
printf("your choise is %f \n",num1);
printf("in Fahrenheit is %f\n",num2);
}
else
if(unit=='f') //*Fahrenheit to celsius*//
{
printf("enter Fahrenheit degree\n");
scanf("%f",num1);
num2=5/9*(num1-32);
printf("your choise is %f\n",num1);
printf("in celsius is %f\n",num2);
}
return 0;
}