RUN


Given temperature in °C, we have to write a program to convert it in °F and print it on the screen.

To convert Celsius to Fahrenheit, we  use the given formula:

°F=95°C+32

# Algorithm

  1. Input the temperature and store it in c
  2. Calculate the temperature in Fahrenheit using the above formula and store it in f
  3. Print f

Code

#include <iostream>
using namespace std;

int main()

{

	float c;

	cout << "Enter temperature in Celsius\n";	//inputting the temperature

	cin >> c;

	float f = (9 *c) / 5;	//calculating the first part of the formula

	f += 32;	//calculating the remaining part

	cout << "temperature in Fahrenheit:" << f;	//printing the calculated

}

Output

Enter temperature in Celsius
36
temperature in Fahrenheit:96.8

Report Error/ Suggestion

Related Posts:

[yuzo_views]



Interview Questions



CopyRight © 2020

CopyRight © 2020