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);
}
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);
}
Comments
regards
Prashanth shetty
regards
ranjeet singh....
tereko aata hai to tu chalu kar
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
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
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
#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;
}
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 main_menu (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 list_menu();
/*int main()
{
printf("***************************************************************\n");
printf("***************************************************************\n");
printf("*** ***\n");
printf("*** SELAMAT DATANG ***\n");
printf("*** ***\n");
printf("***************************************************************\n");
printf("***************************************************************\n");
getchar();
}*/
void main_menu()
{
int selection=0;
int i=0;
while ((selection = list_menu())!=5)
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;
}
}
/*menu*/
int list_menu()
{
int selection;
printf("how may i help you????\n-------------------------\n");
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");
printf("\n\n\n\n\nPlease enter your choice : ");
scanf_s("%d", &selection);
return selection;
} /* Main_Menu */
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
How May I Help You?
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
How May I Help You?
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
How May I Help You?
1. Convert Celsius to Fahrenheit
2. Convert Fahrenheit to Celcius
3. Print Converter Table
4. End
Selection: 4
Press any key to continue…