Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 13

LAB PROGRAMS

1. Finding the area and circumference of a circle of given


radius

#include<stdio.h>
void main()
{
int r;
float area, cir;
printf("\nEnter radius of circle: ");
scanf("%d", &r);
area = 3.14 * r * r;
cir = 2 * 3.14 * r;
printf("\nArea of circle : %f ", area);
printf("\nCircumference : %f ", cir); Output :
}
2. Finding the volume of a sphere of given radius.

#include<stdio.h>
void main()
{
int r;
float volume_sphere;
clrscr();
printf("Enter Radius : ");
scanf("%d",&r);
volume_sphere = (4/3.0)*3.14*r*r*r;
printf("\nVolume of Sphere = %f",volume_sphere);
} Output :
3. Finding the lateral surface area of a right circular cone of given
base radius and height.
#include<stdio.h>
#include<math.h>
void main()
{
float lsa,r,h;
clrscr();
printf("enter radius,height values");
scanf("%f%f",&r,&h);
lsa=3.14*r*(sqrt(h*h+r*r));
printf("lateral surface area of right circular cone:=%f",lsa);
}
Output :
4. Finding selling price of an item, given its cost price
and profit percent.
#include<stdio.h>
void main()
{
float sp;
int cp,pp;
clrscr();
printf("enter cp,pp values");
scanf("%d%d",&cp,&pp);
sp=((100+pp)/100.0)*cp;
printf("Selling price of an item is:=%f",sp);
}
Output :
5. Finding the interest on a given principal for a given period of
time at a given rate of per year.
#include <stdio.h>
void main()
{
int p,t,r;
float i;
printf("Enter p,t,r values : ");
scanf("%d%d%d",&p,&t,&r);
i=(p*t*r)/100.0;
printf("The interest is : %f\n",i);
}
Output :
6. Write a C program to display all the sizes of data types in C.
#include<stdio.h>
void main()
{
clrscr();
printf("\n size of char : %d byte(s)",sizeof(char));
printf("\n size of int : %d byte(s)",sizeof(int));
printf("\n size of long int : %d byte(s)",sizeof(long int));
printf("\n size of short int : %d byte(s)",sizeof(short int));
printf("\n size of float : %d byte(s)",sizeof(float));
printf("\n size of double : %d byte(s)",sizeof(double));
printf("\n size of long double : %d byte(s)",sizeof(long double));
}
Output :

You might also like