Question
write in C code

23. Write a program to generate a table of conversions from Celsius to Rankin. Allow the user to enter the starting temperatu
0 0
Add a comment Improve this question Transcribed image text
Answer #1

In this C program

- We are accepting a starting temperature and increment from the user and store it in the start and inc variables respectively.

- We are requesting the user to enter the file name(You can give your own file name statistically)

(For understanding Purpose, Here, we are accepting the file name from the user)

- Based on the Formula Fahrenheit = (celsius* (float)9 / 5) + 32 we are converting using for loop for 25 times

- Finally, printing to the console along with writing the table to the given filename

Program:

#include<stdio.h>
#include <string.h>
int main()
{

//Temperature conversion variables
float start,end;
int inc,i=0;
int celsius,fahr;

//File pointer variables
FILE *fp;
char fName[20];

//Accepting starting and increment values from the user
printf("Enter the starting temperature: ");
scanf("%f",&start);
printf("Enter the increment: ");
scanf("%d",&inc);

//Accepting a filename to store the data
printf("\nEnter file name to create :");
scanf("%s",fName);

//creating and opening a file
fp=fopen(fName,"w");

//check file created or not
if(fp==NULL)
{
printf("File does not created!!!");
exit(0); /*exit from program*/
}

//Converting from Celsius to Fahrenheit(Rankin)
fprintf(fp,"Celsius\t\tFahrenheit\n");
for(i=0;i<25;i++)
{

float fahrenheit = (start * (float)9 / 5) + 32;
//storing data into a file
fprintf(fp,"%.2f\t\t%.2f\n ", start, fahrenheit);
//Printing the data to the console
printf("%.2f\t\t%.2f\n",start,fahrenheit);
start=start+inc;

}

fclose(fp);

return 0;
}
main.c x #include<stdio.h> #include <string.h> int main() El { //Temperature conversion variables float start, end; int inc,i

// Converting from Celsius to Fahrenheit (Rankin) fprintf(fp,Celsius\t\tFahrenheit\n); for(i=0;i<25;i++) in wwww OLO CO w f

Output:

11 IULICUJUJ_U_LUTILI uy ILIJIU-- BUA Enter the starting temperature: 100 Enter the increment: 10 Enter file name to create :

A Temperature.txt - WordPad File Home View yil 11 12 13 14 Celsius 100.00 110.00 120.00 130.00 140.00 150.00 160.00 170.00 18

Hope this Helps!!!

If not please comment, I will Help you with that...

Add a comment
Know the answer?
Add Answer to:
write in C code 23. Write a program to generate a table of conversions from Celsius...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 2 Write a program to generate a table of conversions from Fahrenheit to Celsius for...

    Question 2 Write a program to generate a table of conversions from Fahrenheit to Celsius for values from 0 degrees F to 100 degrees F. Print a line in the table for each 5-degree change. Use a while loop in your solution. 1) re,-(TCF)-32) x 5/9 Write a program to generate a table of conversions from Fahrenheit to Kelvin for values from 0 degrees F to 200 degrees F. Allow the user to enter the increment in degrees Fahrenheit between...

  • Question 2 nter cost of each 1tem seperated bycespace Enter zero when you are done: 1...

    Question 2 nter cost of each 1tem seperated bycespace Enter zero when you are done: 1 5687 Total cost is: $27 ndter dollar amount: $100 hange due is $73 Use a for loop to determine the sum of all odd integers from I to 100 which is divisible by 3. Print the final sum. (use modulus % to check whether the number is divisible by 3) 2) Write a program to generate a table of conversions from Celcius to Rankin....

  • Write a program that displays a table of Celsius temperatures 0 through a number entered by...

    Write a program that displays a table of Celsius temperatures 0 through a number entered by the user and their Fahrenheit equivalents as in the figure below. The formula for converting a Celsius temperature to a Fahrenheit temperature is: F = 9 / 5 * C + 32 where F is the Fahrenheit temperature and C is the Celsius Temperature. Your program must use a 'for' loop. Display all temperatures to one decimal place. Write a program that displays a...

  • Write a PYTHON program that allows the user to navigate the lines of text in a...

    Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...

  • Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The...

    Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning...

  • FOR PYTHON Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice...

    FOR PYTHON Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom functionc_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a...

  • Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The...

    Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning...

  • C++ Code needed    Celsius Temperature Table The formula for converting a temperature from Fahrenheit to...

    C++ Code needed    Celsius Temperature Table The formula for converting a temperature from Fahrenheit to Celsius is C =5/9(F -32) where F is the Fahrenheit temperature and C is the Celsius temperature. Write a function named celsius that accepts a Fahrenheit temperature as an argument. The function should return the temperature, converted to Celsius. Demonstrate the function by calling it in a loop that displays a table of the Fahrenheit temperatures 0 through 20 and their Celsius equivalents.

  • in c++ please Write a program in c+ to do the following: 1.Save the data shown...

    in c++ please Write a program in c+ to do the following: 1.Save the data shown below (in the same format) to make a text file called "InputData. txt"; use the file as input to enter data into a hash table. Fname Lname 2019-01-31 First Last 2018-02-01 Jonh Doe 2017-03-28 Jane Doe 2016-04-01 as the data items in the file 2. Your hash table should have as many entries 3. The birthday should be used as the hash key by...

  • Write a program in C that will convert all 12 months' average temperature from Celsius to...

    Write a program in C that will convert all 12 months' average temperature from Celsius to Fahrenheit. You need to create an array named aye jump and prompt the user to input average temperature in Celsius for all 12 months. After that, you need to develop a user temperatures from Celsius to Fahrenheit and pass the array as reference and convert all temperatures from Celsius to Fahrenheit. Next, compute the average temperature of the year and assign it to a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT