Joined
·
21,146 Posts
My head hurts, I am tired and I spelled Celsius wrong in my program (but that's besides the point). I need help with this:
Write a program to generate a table of conversions from Celsius to Rankin. Allow the user to enter the starting temperature and increment between lines. Print 25 lines in the table. Use a for loop in your solution.
Code:
Write a program to generate a table of conversions from Celsius to Rankin. Allow the user to enter the starting temperature and increment between lines. Print 25 lines in the table. Use a for loop in your solution.
Code:
Code:
//----------------------------------------------------------------------------------------------------------
// Sean Webster
// Assignment 3
// This program solves Problems 40, 42, and 44 on pages 78-79 of the text.
#include <stdio.h>
#include <math.h>
#define PI 3.141593
int main()
{
// Declare and initialize variables for problem
double initial, increment, final;
double C, F, R, celcius;
// ask for initial input
printf("input initial: ");
scanf("%lf", &initial);
// ask for increment
printf("input increment: ");
scanf("%lf", &increment);
// calculate final so = to 25 lines for table
// floor((final - initial)/(inc))+1
final = ((25*initial) + increment) + 1
// Print celcius to rankin in a loop
printf("celcius to rankin");
for (celcius=initial; celcius<=final; celcius+=increment)
{
// convert from celcius to rankin
F = ((9.0/5)*initial) + 32
R = F + 459.67
// Show tables of celcius and rankin
printf("%.2lf %.2lf \n", initial, R);
}
// Separate the programs
printf("--------------------------------------------------------------------------------");
// Exit program
getchar();
return 0;
}
//----------------------------------------------------------------------------------------------------------