Objective: C Program for Conversion of temperature from Celsius to Fahrenheit
Analysis:
Input : Celsius Temperature
Output : Fahrenheit Temperature
Constraints : F = (C * 9/5)+32
Algorithm:
Step1. Start
Step2. Enter Celsius temperature value
Step3. Read Celsius temperature value
Step4. Fahrenheit Temperature = (C * 9/5)+32
Step5. Display Fahrenheit Temperature
Step6. Stop
Flow Chart:
Implementation:
/* Conversion of Temperature from Celsius to Fahrenheit */
#include<stdio.h>
#include<conio.h>
void main( )
{
int c;
float f;
clrscr( ); //Clear Previous Screen Contents
printf("\nEnter Celsius temperature: ");
scanf("%d", &c);
f = (c * 9/5)+32;
printf("\nFahrenheit Temperature is %f",f);
getch( );
}
Compilation & Execution:
In linux:
Step1:
gcc ctof.c
Step2:
./a.out
In Windows(Turbo C)
Step1:
ALT + F9( Compiling )
Step2:
F9( Linking )
Step3:
CTL + F9( Execution )
Output:
Enter Celsius temperature: 32
Fahrenheit Temperature is 93.2000
Source File: CtoF.C
Analysis:
Input : Celsius Temperature
Output : Fahrenheit Temperature
Constraints : F = (C * 9/5)+32
Algorithm:
Step1. Start
Step2. Enter Celsius temperature value
Step3. Read Celsius temperature value
Step4. Fahrenheit Temperature = (C * 9/5)+32
Step5. Display Fahrenheit Temperature
Step6. Stop
Flow Chart:
Fig: Flow Chart for Conversion of Celsius to Fahrenheit
Implementation:
/* Conversion of Temperature from Celsius to Fahrenheit */
#include<stdio.h>
#include<conio.h>
void main( )
{
int c;
float f;
clrscr( ); //Clear Previous Screen Contents
printf("\nEnter Celsius temperature: ");
scanf("%d", &c);
f = (c * 9/5)+32;
printf("\nFahrenheit Temperature is %f",f);
getch( );
}
Compilation & Execution:
In linux:
Step1:
gcc ctof.c
Step2:
./a.out
In Windows(Turbo C)
Step1:
ALT + F9( Compiling )
Step2:
F9( Linking )
Step3:
CTL + F9( Execution )
Output:
Enter Celsius temperature: 32
Fahrenheit Temperature is 93.2000
Source File: CtoF.C
0 comments:
Post a Comment