C Program for converting temperature from Celsius to Fahrenheit
#include<stdio.h>
#include<conio.h>
void main()
{
float c,f;
clrscr();
printf("Enter the temperature in celsius:");
scanf("%f",&c);
f=c*9/5+32;
printf("Temperature in Fahrenheit=%.2f",f);
getch();
}
Example-2
C Program for printing grade to the student based on the percentages given below
>75-------> A+
70-75-----> A
60-70----->B
below 60-->C
#include<stdio.h>
#include<conio.h>
void main()
{
int m,p,c,sum;
float avg;
clrscr();
x: printf("Enter the marks Maths Physics Chemistry:");
scanf("%d%d%d",&m,&p,&c);
if(m<0||m>100||p<0||p>100||c<0||c>100)
goto x;
sum=m+p+c;
avg=(float)sum/3;
printf("Maths=%d\nPhysics=%d\nChemistry=%d\nSum=%d\nAverage=%.2f\n",m,p,c,sum,avg);
m<35||p<35||c<35?printf("Fail"):avg>75?printf("Grade=A+"):avg>70?printf("Grade=A"): avg>60?printf("Grade=B"):printf("Grade=C");
getch();
}
Example-3
C Program for calculating income tax based on salary of the employee details given belowSalary----->tax%
----------------------
>500000-------> 10%
300000-500000 -->7%
100000-300000 --->5%
50000-100000 ---->3%
<50000 ---------->0%
#include<stdio.h>
#include<conio.h>
void main()
{
float inc,t,sal;
clrscr();
printf("Enter the salary:");
scanf("%f",&sal);
t=sal>500000?10:sal>300000?7:sal>100000?5:sal>50000?3:0;
inc=sal*t/100;
printf("Tax=%.2f\nIncome tax=%.2f",t,inc);
getch();
}