Problem 06

author
By Supreme2023-02-14
Problem Statement :
Write a program to compute Fahrenheit from centigrade (f=1.8*c +32)
Code:

#include <stdio.h>

int main()
{

// 6. Write a program to compute Fahrenheit from centigrade (f=1.8*c +32)

printf("\tTemprature Converter");
printf("\n===========================================");

float tampf, tampc;

printf("\n\nEnter The Tamprature In Celsius : ");
scanf("%f", &tampc);

tampf = 1.8 * tampc + 32;

printf("\n___________________________________________");

printf("\n\n%.2f Degree Celsius In Fahrenheit : %.2f", tampc, tampf);

printf("\n\nFormula used (f=1.8*c +32)");

printf("\n___________________________________________\n\n");
return 0;
}

Description :
  • This C program prompts the user to input a temperature in degrees Celsius and then converts the temperature to Fahrenheit using the formula f = 1.8 * c + 32.
  • First, the program prints a message to the console informing the user that they will be converting a temperature. Then, the program prompts the user to enter a temperature in Celsius using the scanf() function.
  • After the user inputs the temperature, the program calculates the corresponding temperature in Fahrenheit using the formula and assigns the result to the variable tampf. The program then prints the converted temperature to the console using printf().
  • Finally, the program prints the formula used to convert the temperature and a separator line before returning 0 to indicate successful completion.
Output Image:
Output-image

© Copyright 2022. All right reserved, GTU Coder.