-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03rd_program.c
More file actions
36 lines (28 loc) · 1.18 KB
/
03rd_program.c
File metadata and controls
36 lines (28 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//Write a program that covert temperature from Celsius to Fahrenheit and vice versa.
#include <stdio.h>
int main()
{ int select;
float celsius,fahrenheit;
float convert_to_fahrenheit, convert_to_celsius;
printf("Enter 1 to convert celsius to fahrenheit \n");
printf("Enter 2 to convert fahrenheit to celsius \n");
printf("Enter 1 or 2 from options: ");
scanf("%d",&select);
switch(select)
{
case 1: printf("Enter requested detail for temperature conversion \n");
printf("Enter celsius : ");
scanf("%f",&celsius);
convert_to_fahrenheit=(celsius*9/5)+32;
printf("%f celsius into fahrenheit =%f \n",celsius,convert_to_fahrenheit);
break;
case 2: printf("Enter requested detail for temperature conversion \n");
printf("Enter fahrenheit : ");
scanf("%f",&fahrenheit);
convert_to_celsius=(fahrenheit-32)*5/9;
printf("%f fahrenheit into celsius =%f \n",fahrenheit,convert_to_celsius);
break;
default: printf("You have entered invalid input! \n");
}
return 0;
}