C program to convert Temperature from degree Celsius to Fahrenheit and Fahrenheit to Celsius.
In this program we will learn how to write a c program that convert Temperature from Fahrenheit to Celsius and Celsius to Fahrenheit.
Here we will write a c program that solve both operations as Fahrenheit to Celsius and Celsius to Fahrenheit.
This program provides a choice to user that which operation will be execute.
In this program choice1 is: ENTER 1 FOR CONVERT FAHRENHEIT TO CELSIUS.
And choice2 is: ENTER 2 FOR CONVERT CELSIUS TO FAHRENHEIT."
To make a C program to convert Temperature from Fahrenheit to Celsius and Celsius to Fahrenheit we will use simple mathematical formulas which are as:
Formula for Fahrenheit to Celsius conversion:-
Celsius=((Fahrenheit-32)*(5/9.0))
Formula for Celsius to Fahrenheit conversion:-
Fahrenheit=(Celsius*1.8)+32
In this output we can see that it is a Temperature converter.
This program provides a choice to user that which operation will be execute.
if we will enter 1 then it converts Temperature from Fahrenheit to Celsius if we will enter 2 then it converts Celsius to Fahrenheit .
If we will enter any other number from 1 or 2 then it is print WRONG ENTRY.
In this program we will learn how to write a c program that convert Temperature from Fahrenheit to Celsius and Celsius to Fahrenheit.
Program Description:
Here we will write a c program that solve both operations as Fahrenheit to Celsius and Celsius to Fahrenheit.
This program provides a choice to user that which operation will be execute.
In this program choice1 is: ENTER 1 FOR CONVERT FAHRENHEIT TO CELSIUS.
And choice2 is: ENTER 2 FOR CONVERT CELSIUS TO FAHRENHEIT."
To make a C program to convert Temperature from Fahrenheit to Celsius and Celsius to Fahrenheit we will use simple mathematical formulas which are as:
Formula for Fahrenheit to Celsius conversion:-
Celsius=((Fahrenheit-32)*(5/9.0))
Formula for Celsius to Fahrenheit conversion:-
Fahrenheit=(Celsius*1.8)+32
C program code
#include<stdio.h>
#include<conio.h>
void main()
{
float c,f;
int choice;
clrscr();
printf("\n ENTER 1 FOR CONVERT FAHRENHEIT TO CELSIUS.");
printf("\n ENTER 2 FOR CONVERT CELSIUS TO FAHRENHEIT.");
printf("\n");
printf("\n ENTER YOUR CHOICE:\n ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("\n ENTER THE VALUE OF FAHRENHEIT:\n " );
scanf("%f",&f);
c=((f-32)*(5/9.0));
printf("\n THE VALUE OF CELSIUS:\n %f",c);
break;
case 2:
printf("\n ENTER THE VALUE OF CELSIUS:\n " );
scanf("%f",&c);
f=(c*1.8)+32;
printf("\n THE VALUE OF FAHRENHEIT:\n %f",f);
break;
default:
printf("\n WRONG ENTRY.");
}
getch();
}
OUTPUT:
In this output we can see that it is a Temperature converter.
This program provides a choice to user that which operation will be execute.
if we will enter 1 then it converts Temperature from Fahrenheit to Celsius if we will enter 2 then it converts Celsius to Fahrenheit .
If we will enter any other number from 1 or 2 then it is print WRONG ENTRY.
Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com
Created by-- HARSH CHAUHAN
No comments:
Post a Comment