100% found this document useful (1 vote)
82 views

Some Additional Programs For Examples

These C programs demonstrate how to convert Celsius to Fahrenheit, calculate gross salary using if/else statements, find voltage using Ohm's Law, calculate the area of a circle, find simple interest, calculate a discounted amount using an if statement, and find the factorial of a number.

Uploaded by

Vignesh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
82 views

Some Additional Programs For Examples

These C programs demonstrate how to convert Celsius to Fahrenheit, calculate gross salary using if/else statements, find voltage using Ohm's Law, calculate the area of a circle, find simple interest, calculate a discounted amount using an if statement, and find the factorial of a number.

Uploaded by

Vignesh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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();
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy