## Monday, June 26, 2006

### C Program to Convert Celcius to Fahrenheit and vice versa

This Program converts the Temperature from Fahrenheit to Celcius and vice versa.
Mind you, the formula for the conversion is just a multiplication by a factor one.

The conversion if non-linear and the logic is included in the program itself.

Temperature of a city in Fahreinheit degrees is input through the keyboard.
Write a program to convert this temerature into Centigrade degrees.

/*To convert Fahrenheit to Celsius, subtract 32 degrees and divide by 1.8.
To convert Celsius to Fahrenheit, multiply by 1.8 and add 32 degrees.*/

#include<stdio.h>

main ()
{
float temp_c, temp_f;

printf ("Enter the value of Temperature in Celcius: ");

scanf ("%f", &temp_c);

temp_f = (1.8 * temp_c) + 32;

printf ("The value of Temperature in Fahreinheit is: %f", temp_f);

}

Anonymous said...

Thnxs Mr copper skull,..ur code helped me a lot,..

regards

Prashanth shetty

Anonymous said...

thanks dude

raj's world said...

thnx mr. copper skull very much....

regards

ranjeet singh....

Naresh said...

can u please post a program which reads both celcius and fahrenheit and converts its to the opposite.... means if celsius is given then it shud convert to fahrenheit and is fahrenheit is give it shud convet it to celsius... both calculations in a single program.... please...

chlue said...

Any luck with that program I have virtually the same question and I have no idea what to do.

lund_chut said...

are gaandu koi tuff se program bana na

Anonymous said...

gaandu hoga tera baap.
tereko aata hai to tu chalu kar

Anonymous said...

#include

int main(void)
{
// Local Declarations
float Celsius, Fahrenheit, Fahrenheit_1, Celsius_2;

// Statements
printf("Enter the temperature in Fahrenheit: ");
scanf("%f", &Fahrenheit);
printf("Fahrenheit temperature is: %5.1f F\n\a", Fahrenheit);

Celsius = (100.0 / 180.0) * (Fahrenheit - 32);

printf("Celsius temperature is: %8.1f C\n\n\a", Celsius);

system("pause");
system("cls");

printf("Enter the temperature in Celsius: ");
scanf("%f", &Celsius_2);
printf("Celsius temperature is: %8.1f C\n\a", Celsius_2);

Fahrenheit_1 = 32 + (Celsius_2 * (180.0 / 100.0));

printf("Fahrenheit temperature is: %5.1f F\a", Fahrenheit_1);

system("pause");
return 0;
}// main

Samrocks said...

Thanksss ur code helped me a lot as i m a beginner to c programming

Anonymous said...

allan said...

A C program is required to read in temperatures in degrees Fahrenheit and to convert these values into their equivalent in degrees celcius.
formula:
degrees celcius= (5/9)*(F-32)

write down appropriate statement :
(i) to read in value in fahrenheit
(ii)to convert the temperature
(iii)to output the equivalent temperature in degrees celcius

Can anyone help me how to do this ? itz a C programming

allan said...

write an appropriate control structure that will examine the value of a floating point variable called marks and print one of the following messages depending on the value assigned to marks.

PASS(if the value is in the range 40-50)
PROMOTED(if the value of marks is greater than 50)
FAIL(if the value of marks is less than 40)

ANyone can help, am new to C programming

Anonymous said...

Please, give the algorithm and flowchart of the program.

Anonymous said...

thanks Mr. Copper

Anonymous said...

thanx this helped me in my exam thakew

Anonymous said...

Hi am new to c programming...been workin on a project which is som kinda guessin game...my problem is that I do not know how to keep the console from closing after first input...this is the code

#include

int main()
{

int mybday = 20; //declare variable to be guessed
int guess; //declare variable to store guessed date
int max = 31; //declare variable to test for invalid input
int min = 1; //declare variable to test for invalid input

printf("Try to guess the day of my Birthday: "); //display the intro and

scanf("%d",&guess); //`get the users guess and store it in the

if (guess == mybday)
{
printf("OK Fine! You got it! \n \n"); //print you win if guess is correct
}
else if (guess < min)
{
printf("Kwani is that a DATE?"); //print `Error for invalid input
scanf("%d",&guess);
}
else if (guess > max)
{
printf("There isn't %d days in a month!",guess); //print Error for

}
else if (guess > mybday)
{
printf("Am Not That OLD!"); //print too high if guess is above answer
}
else if (guess < mybday)
{
printf("Hey! Am Not That YOUNG!"); //print too low if guess is below answer
}
else
{
printf("Looser!!"); //Print try again if guess if all else is not

}

return 0;

}

nisha saha said...

tnks a lot , i'm new 2 c, u'r prgrm hlpd me a lot

nisha saha said...

tnks a lot

Anshika said...

I want output of temperature conversion in c software.

Anonymous said...

fucker

nur_sha said...
This comment has been removed by the author.
nur_sha said...

Write a program that will convert from Celsius to Fahrenheit and vice versa. The program should also
print the table as requested by the user. Create at least two (2) functions, Celsius_Fahrenheit and
Fahrenheit_Celsius to do the conversion. You can also create a menu to simplify the selection
process.
so if i can get the coding that used switch function..i tried to do the menu but i cant detect my mistake here.and i can appear the output

#include
#include

int celsius;
int farenheit;
float tot_calc_temp_celsius;
float tot_calc_temp_ferenheit;
float tot_calc_temp;

void celsius_convert(void);
void farenheit_convert(void);
void calc_temp_celsius(int celsius);
void calc_temp_farenheit(int ferenheit);
void print_record(void);
void print_record( int n);
void print_record2(int j);
void print_statement(float tot_calc_temp);
void swap(int a, int b);
void check_line_printed(int *line_printed, int max_line);

/*int main()
{
printf("***************************************************************\n");
printf("***************************************************************\n");
printf("*** ***\n");
printf("*** SELAMAT DATANG ***\n");
printf("*** ***\n");
printf("***************************************************************\n");
printf("***************************************************************\n");
getchar();

}*/

{
int selection=0;
int i=0;

switch ( selection)
{
case 1 :celsius_convert();
break;
case 2 :farenheit_convert();
break;
case 3 :print_record();
break;
case 4 :exit(1);
break;
default:
printf("invalid selection\n");
break;

}
}
{
int selection;

printf("%4c\t%s\n%4c\t%s\n%2c\t%s\n%3c\t%s\n",
'1', "convert farenheit into celsius",
'2', "convert celsius into farenheit",
'3', "print table",
'4', "Exit\n");

scanf_s("%d", &selection);

return selection;

mya.aziz@yahoo.com said...

hey will you guys help me on this. here is the question.
if you guys know please let me know tru email. thanks

Write a program that will convert from Celsius to Fahrenheit and vice versa. The program should also print the table as requested by the user. Create at least two (2) functions, Celsius_Fahrenheit and Fahrenheit_Celsius to do the conversion. You can also create a menu to simplify the selection process. The more function you created, the more marks you will get. An EXAMPLE of output program is as below:
Welcome to Temperature Converter
1. Convert Celsius to Fahrenheit
2. Convert Fahrenheit to Celcius
3. Print Converter Table
4. End

Selection: 1
Please enter value in Celsius: 0
0 degree Celsius is equivalent to 32 degree Fahrenheit
1. Convert Celsius to Fahrenheit
2. Convert Fahrenheit to Celcius
3. Print Converter Table
4. End

Selection: 3
Please choose 1. Celsius or 2. Fahrenheit: 1
Enter your starting value in Celsius: 2
Enter your end value in Celsius: 7
Printing Chart…
Celsius Fahrenheit
2 35.60
3 37.40
4 39.20
5 41.00
6 42.80
7 44.60
1. Convert Celsius to Fahrenheit
2. Convert Fahrenheit to Celcius
3. Print Converter Table
4. End

Selection: 4
Press any key to continue…

Anonymous said...

thnx a lot for d code, but mine closes before displaying the results,can you pls help me with that.

Anonymous said...

thanx a lot for the code,but mine closes before displaying the results you help me with that...

Vuciri Denis Stephen said...

write a logarithms and c programming to change temperature from Celsius to Fahrenheit. when f=(9/5 + 32)

ChristianV said...

You need to run the program w/out debugging for it to run and display the output on screen. If you are using Microsoft Visual C++ Express look under the Debug menu and select "Star Without Debugging" or just press Ctrl+F5.

Thanks for this

Anonymous said...

You can convert temperature from degrees Celsius to degrees Fahrenheit by multiplying by 9/5 and adding 32. Write a program that allows the user to enter a floating-point number representing degrees Celsius, and then displays the corresponding degrees Fahrenheit

Anonymous said...

plz do rply for dis question..

Anonymous said...

thnk u its very good

Anonymous said...

thanks for this code thanks again

Anonymous said...

thanx.I am a fresher to c & ur programme helped a lot.Thnx Mr.copper skull very much....

Anonymous said...

can we use loop for this program?

Anonymous said...

thank u copperskull. it is really helpfull

Leslie Lim said...

Wow. Awesome article. Please do more articles like this in the future. Very informational and knowledgeable. I will expect more from you in the future. For now i will just bookmark your page and surely I'm gonna come back later to read more. Thank you to the writer!

Rica
www.imarksweb.org