Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am getting wrong outputs on my temperature conversion program in C. Not sure w

ID: 3770669 • Letter: I

Question

I am getting wrong outputs on my temperature conversion program in C.

Not sure where to change exactly.

#include<stdio.h>
float convertFtoC(int);
int main(){

float cels;
   int fahr;
   int i = 0;

   printf("Please enter a maximum temperature in Fahrenheit (F)");
   scanf("%d", &fahr);

    while(fahr < 0)
   {
   printf("Wrong Input ");
       printf("Select new value: ");
       scanf("%d", &fahr);
   }
   while(i <= fahr)
   {
       cels = convertFtoC(fahr);
       printf("Temperature in F Temperature in C ");
       printf("%d%22.2f ", i, cels);
       i = i + 5;
   }
   return 0;
}
float convertFtoC(int f)
{
   float c;
   c = ((f - 32) * (5/9));
   return c;
}

Explanation / Answer

#include <stdio.h>
float convertFtoC(int);
int main(){
float cels;
int fahr;
int i = 0;
printf("Please enter a maximum temperature in Fahrenheit (F)");
scanf("%d", &fahr);
while(fahr < 0)
{
printf("Wrong Input ");
printf("Select new value: ");
scanf("%d", &fahr);
}
while(i <= fahr)
{
cels = convertFtoC(i);
printf("Temperature in F Temperature in C ");
printf("%d%22.2f ", i, cels);
i = i + 5;
}
return 0;
}
float convertFtoC(int f)
{
float c;
c = ((f - 32) * (5.0/9));
return c;
}