Professional Documents
Culture Documents
4.1 Program To Convert Celsius To Fahrenheit: Ex - No:4 C Programming Using Simple Statements and Expression
4.1 Program To Convert Celsius To Fahrenheit: Ex - No:4 C Programming Using Simple Statements and Expression
No:4
Step 1:
Step 2:
Step 3:
Step 4:
Step 5:
Start.
Read the Input cl (i.e) temperature in Celsius.
Convert the Celsius value to Fahrenheit value by using the
calculation fh=(1.8 * cl) + 32.
Print the output fh (i.e) the equivalent Fahrenheit value
Stop.
PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
float fh,cl;
clrscr();
printf("enter temperature value in Celsius:");
scanf("%f",&cl);
fh=(1.8 * cl)+32;
printf("converted Fahrenheit value :%f", fh);
getch();
return 0;
}
OUTPUT:
Step 1:
Step 2:
Step 3:
Step 4:
Start.
Read the number n
Check the condition if(n%2) ==0, if the condition is true
Step3.1 : print The number is even
Step3.2 : print The number is odd
Stop
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf(Enter the Number:);
scanf(%d,&n);
if(n%2==0)
printf(\n The number is even );
else
printf(\n The number is Odd);
getch();
}
OUTPUT:
Enter the Number
6
The number is even
Enter the Number
87
The number is odd
Step 1:
Step 2:
Step 3:
Start.
Read three numbers a,b,c
Check the condition if (a>b && a>c), if the condition is true
Step 3.1: print a is the greatest number
Step 4:
Else, check the condition if (b>a && b>c), if the condition is true
Step 5:
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
Int a,b,c;
clrscr();
printf(Enter three numbers:\n);
scanf(%d%d%d,&a,&b,&c);
if(a>b&&a>c)
printf(%d is the greatest,a);
else if(b>a && b>c)
printf(%d is the greatest,b);
else
printf(%d is the greatest,c);
getch();
}
OUTPUT:
Enter three numbers
58
60
40
60 is the greatest
AIM:
ALGORITHM:
Step 1:
Step 2:
Step 3:
Start.
Read the variable number.
Assign the variable number to originalNumber.
Step 4:
Step 5:
Step 6:
End
PROGRAM:
#include <stdio.h>
int main()
{
int number, originalNumber, remainder, result = 0;
printf("Enter a three digit integer: ");
scanf("%d", &number);
originalNumber = number;
while (originalNumber != 0)
{
remainder = originalNumber%10;
result += remainder*remainder*remainder;
originalNumber /= 10;
}
if(result == number)
printf("%d is an Armstrong number.",number);
else
printf("%d is not an Armstrong number.",number);
return 0;
}
OUTPUT: