Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Temperature Conversions) Write a program that converts integer Fahrenheit temperatures from 0 to 212 degrees to floating-point Celsius temperatures with 3 digits of precision. Perform

(Temperature Conversions) Write a program that converts integer Fahrenheit temperatures from 0 to 212 degrees to floating-point Celsius temperatures with 3 digits of precision. Perform the calculation using the formula

celsius = 5.0 / 9.0* (fahrenheit - 32);

The output should be printed in two right-justified columns of 10 characters each, and the Celsius temperatures should be preceded by a sign for both positive and negative values.

#include

int main()

{

//Store temp in Fahrenheit

int temp_fahrenheit;

//store temp in Celsius

float temp_celsius;

printf(" Temperature conversion from Fahrenheit to Celsius is given below: ");

printf(" %10s\t%12s ", "Fahrenheit", "Celsius");

//For loop to convert

for (temp_fahrenheit = 0; temp_fahrenheit <= 212; temp_fahrenheit++)

{

temp_celsius = 5.0 / 9.0 *(temp_fahrenheit - 32);

printf("%10d\t%12.3f ", temp_fahrenheit, temp_celsius);

}// End loop

return 0;

}

This is my code and it works, but I am looking specifically for different ways to write this code or is this the only way?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

Distinguish between dispersed and concentrated disconfirmation.

Answered: 1 week ago

Question

What are the purposes of collection messages? (Objective 5)

Answered: 1 week ago