Rich (BB code):
#include<stdio.h>
#include<ctype.h>
void work(void);
double fah_2_cels(double fahr );
double cels_2_fahr(double cels);
int main(void)
{
char more;
puts("\n enter the temperature followed by f for fahr and c for cels");
do{
work();
puts("\n do you want to continue(Y/N)?");
scanf("%c" ,&more);
more =toupper(more);
}while(more!='N');
return 0;
}
void work(void)
{
double temp;
//char ch[6];
double num,fahr,cels;
printf("enter the temperature");
scanf("%lg %c",&num,&num);
if (num='70')
{
temp=fah_2_cels(num);
printf("temperature in cel is %g",temp);
}
else
temp=cels_2_fahr(num);
printf("temperature in fahr is %g",temp);
}//closes void work()
double fah_2_cels(double fahr)
{
return ((5.0/9.0)*(fahr-32.0));
}
double cels_2_fahr(double cels)
{
return ((9.0/5.0)*cels +32.0); //If you find that the results are off look at these functions
}
thanks
Last edited: