Sunteți pe pagina 1din 7

To convert Celsius temperature into Fahrenheit

temperature

#include <stdio.h>
#include <conio.h>
void main ()
{clrscr();
float f;
float c;
printf("Enter Temp. in Celcius");
scanf("%f",&c);
f=1.8*c+32.0;
printf("Temperature in Fahrenheit is");
printf("%f",f);
getch();
}

1
To find the gross salary by using if-else statement

#include<stdio.h>
#include<conio.h>
void main()
{ clrscr();
int Basic;
float HRA;
float PF;
float Total;
printf("Enter Basic Salary = ");
scanf("%d",&Basic);
if (Basic<=5000)
{HRA=Basic/10;
PF=200;
Total=Basic+HRA+PF;}
else
{HRA=700;
PF=300;
Total=Basic+HRA+PF;
}
printf("Gross Salary = Rs.%f",Total);
getch();
}

2
To find voltage using Ohm’s Law

#include <stdio.h>
#include <conio.h>
void main ()
{clrscr();
float I;
float R;
float V;
printf("Enter the value of Current,I=");
scanf("%f",&I);
printf("Enter the value of Resistance,R=");
scanf("%f",&R);
V=I*R;
printf("The required Voltage,V=");
printf("%f",V);
getch();
}

3
To find area of circle

#include<stdio.h>
#include<conio.h>
void main ()
{clrscr();
float r;
float A;
printf("Enter the radius of circle,r = ");
scanf("%f",&r);
A=3.14*r*r;
printf("Area of the circle is = ");
printf("%f",A);
getch();
}

4
To find Simple Interest

#include<stdio.h>
#include<conio.h>
void main()
{clrscr();
float P,R,T,SI;
printf("Enter principle amount,P = ");
scanf("%f",&P);
printf("Enter rate of interest/annum,R = ");
scanf("%f",&R);
printf("Enter time period,T = ");
scanf("%f",&T);
SI=(P*R*T)/100;
printf("The amount of Simple Interest is = ");
printf("%f",SI);
getch();
}

5
To find discounted amount by using if statement

#include<stdio.h>
#include<conio.h>
void main()
{clrscr();
int Qty,Dis=0;
float R,Total,Total1;
printf("Enter the Quantity =Rs ");
scanf("%d",&Qty);
printf("Enter the rate/unit,R =Rs ");
scanf("%f",&R);
Total=Qty*R;
printf("Your bill is =Rs ");
printf("%f",Total);
if(Total>1000)
{
Dis=10;
Total1=(Total)-(Total*Dis/100);
printf("\nCONGRATULATION!\nYou have got
discount.\nYour discounted bill is =Rs ");
printf("%f",Total1);
}
getch();
}

6
To find the factorial of entered number

#include <stdio.h>
#include <conio.h>
void main()
{clrscr();
int num,i;
long int factorial;
printf("Enter the number = ");
scanf("%d",&num);
factorial=i=1;
for(i=1;i<=num;i++)
{
factorial=factorial*i;
}
printf("Required factorial is = ");
printf("%ld",factorial);
getch();
}

S-ar putea să vă placă și