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

Write a program that prints out conversion tables for Celsius to Fahrenheit (0 t

ID: 3633726 • Letter: W

Question

Write a program that prints out conversion tables for Celsius to Fahrenheit (0 to 100) and Fahrenheit to Celsius (32 to 212). Use separate functions to convert Fahrenheit to Celsius and Celsius to Fahrenheit. The output format for each table is to fit on a standard monitor display, 80 columns by 20 rows.

F = 32 + C * (180.0 / 100.0)

So far I found out how to make it print out the conversion, but it's only one per line. I don't know how to make it fit in the 20 x 80 box.
My code so far:
main()
{
float fahr, celsius;
int lower, upper, step;

lower =32;
upper = 212;
step = 1;

fahr = lower;
while (fahr <= upper)
{
celsius = (5.0/9.0) * (fahr-32.0);
printf("%3.0f %6.1f ", fahr, celsius);
fahr = fahr + step;
}
}

Explanation / Answer

please rate - thanks

you didn't use a method

#include <stdio.h>
#include<conio.h>
void celfah();
void fahcel();
int main()
{
celfah();
printf("press any key for fahrenheit to celsius table");
getch();
fahcel();

getch();
return 0;
}
     
void celfah()
{int cel,kt=0;
double fah;
printf("   c     f     c    f      c    f      c    f      c    f      c    f ");
for(cel=0;cel<101;cel++)
     { fah=(9./5.)*cel+32;
    printf("%4d %6.2lf ",cel,fah);
     kt=++kt%6;
     if(kt==0)
        printf(" ");
     }
        printf(" ");    
}        
void fahcel()
{int fah,kt=0;
double cel;
printf("    f    c      f    c     f     c     f     c     f     c     f     c ");
for(fah=32;fah<212;fah++)
     {cel=(5./9.)*(fah-32.);
    printf("%4d %6.2lf ",fah,cel);
     kt=++kt%6;
     if(kt==0)
        printf(" ");
     }
}   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote