Welcome To My Blog!! Enjoy Your Time Reading! - Vino00031

Temperature Conversion Program in C++

A C++ Program That converts Temperatures:
#include<stdio.h>
#include<conio.h>

int main()
{
float temp_fahrenheit, temp_celsius;
char option=’ ‘;
printf("\n Choose type of conversion:");
printf("\n\t[F]ahrenheit to Celsius");
printf("\n\t[C]elsius to Fahrenheit");
printf("\nEnter option: ");
scanf("%c",&option);

switch(option)
{
case ‘F’: case ‘f’:
printf("Enter temperature value in Fahrenheit: ");
scanf("%f",&temp_fahrenheit);
temp_celsius = (temp_fahrenheit – 32) * 5/9;
printf("%.2f degrees Fahrenheit is equal to %.2f degrees Celsius", temp_fahrenheit, temp_celsius);
break;
case ‘C’: case ‘c’:
printf("Enter temperature value in Celsius: ");
scanf("%f",&temp_celsius);
temp_fahrenheit = (temp_celsius * 9/5)+ 32;
printf("%.2Lf degrees Celsius is equal to %.2f degrees Fahrenheit", temp_celsius, temp_fahrenheit);
break;
default:
printf("Unknown option selected.");
break;
}
printf("\nExiting …");
getch();
return 0;
}

No comments:

Post a Comment

GOOGLE AD

Flag Counter

free counters
. . . . . . . . .