Computer Science Practical: X
SLO No 9.2.2
SLOs Mapped 8.3.2, 9.1.1,9.1.2,9.1.3,9.1.5,9.2.2,9.2.3,9.2.4
Practical Activity To convert Celsius to Fahrenheit temperature and vice versa
Equipment Computer
Software Dev C++
Practical No 4
Topic 9: Fundamental of input and output data handling in C
Objective:
Students will be able to
use the arithmetic operators and input output data handling in C language to solve the given
arithmetic problem.
Note: You can use any compiler for program execution.
Fill the sections below as evidence of the practical activity.
Algorithm Flowchart
Celsius to Fahrenheit Celsius to Fahrenheit Fahrenheit to Celsius
Step 1: start
Step 2: input
celcius,fahrenheit
Step 3: celsius =
(Fahrenheit-32)/1.8
Step 4: print celsius
Step5 : stop
Fahrenheit to Celsius
Step 1: start
Step 2: input
Fahrenheit,celcius
7
Computer Science Practical: X
Step 3: fahrenheit =
celcius*1.8 - 32
Step 4: print fahrenheit
Step5 : stop
Program Coding
Celsius to Fahrenheit Fahrenheit to Celsius
#include <stdio.h> #include <stdio.h>
int main() { int main() {
float celsius, fahrenheit; float celsius, fahrenheit;
printf("Enter celsius: "); printf("Enter Fahrenheit: ");
scanf("%f", &celsius); scanf("%f", &fahrenheit);
fahrenheit = (celsius*1.8)+32; celsius = (fahrenheit - 32) / 1.8;
printf("fahrenheit = %f\n", printf("Celsius = %f\n", celsius);
fahrenheit);
return 0;
return 0; }
8
Computer Science Practical: X
}
Program Output
Celsius to Fahrenheit Fahrenheit to Celsius