Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Help please/ need help

0 votes
asked Oct 8, 2018 by Christina1 (310 points)

Start by writing a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is F = (9/5)C + 32 where F is the Fahrenheit temperature and C is the Celsius temperature. Enhance the program by allowing the user to choose between converting from Celsius to Fahrenheit and vice versa. See the below output. You will need to look up the formula for the other directions (simply google it!). Allow for both upper and lower-case menu item selections and generate an appropriate error message if the user enters something unexpected. Format your output to always show one decimal. You will build on this assignment in future chapters.

The output should look something like this:
Enter c (or C) to convert Fahrenheit to Celsius
   or f (or F) to convert Celsius to Fahrenheit: c

Enter the temperature: 0.0
0.0 Celsius is 32.0 degrees Fahrenheit.

Running the program again:
Enter c (or C) to convert Fahrenheit to Celsius
   or f (or F) to convert Celsius to Fahrenheit: F

Enter the temperature: 212
212.0 Fahrenheit is 100.0 degrees Celsius.

1 Answer

0 votes
answered Oct 11, 2018 by Lukas (540 points)
edited Oct 11, 2018 by Lukas
#include <stdio.h>

int main()

    float temperature;
    char which;

    printf("Enter f to convert Fahrenheit to Celsiusor or c to convert Celsius to Fahrenheit: ");
    if (which == 'c')
        printf("\nCelsius: ");
        printf("\n%.1f Grad Celsius correspond", temperature);
        printf(" %.1f Grad Fahrenheit.\a\n",temperature*9/5+32);
    } else if (which == 'f')
        printf("\Fahrenheit: ");
        printf("\n%.1f Grad Fahrenheit correspond", temperature);
        printf(" %.1f Grad Celsius.\a\n",(temperature-32)*9/5);
     printf("\n\aWrong input!\nPlease restart the program");

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.