Simple interest
Simple interest
#include < stdio.h >
void main()
{
int amount, rate, time, ans;
printf("\nEnter Principal Amount : ");
scanf("%d", &amount);
printf("\nEnter Rate of Interest : ");
scanf("%d", &rate);
printf("\nEnter Period of Time : ");
scanf("%d", &time);
ans = (amount * rate * time)/100;
/*Simple interest formula*/
printf("\nSimple Interest : %d",ans);
}
Area of Circle
Area of Circle
#include < stdio.h >
#include < math.h >
#define PI 3.142
void main()
{
float radius, area;
printf("Enter the radius of a circle \n");
scanf("%f", &radius);
area = PI * pow(radius, 2);
printf("Area of a circle = %5.2f\n", area);
}
Area of Rectangle
Area of Rectangle
#include < stdio.h >
#include < conio.h >
int main() {
int length, breadth, area;
printf("\nEnter the Length of Rectangle : ");
scanf("%d", &length);
printf("\nEnter the Breadth of Rectangle : ");
scanf("%d", &breadth);
area = length * breadth;
printf("\nArea of Rectangle : %d", area);
return (0);
}
Area of Square
Area of Square
#include < stdio.h >
int main() {
int side, area;
printf("\nEnter the Length of Side : ");
scanf("%d", &side);
area = side * side;
printf("\nArea of Square : %d", area);
return (0);
}
Volume of Cube
Volume of Cube
#include < stdio.h >
void main()
{
float a;
float surface_area,volume;
printf("Enter size of any side of a cube : ");
scanf("%f",&a);
surface_area = 6 * (a * a);
volume = a * a * a;
printf("Surface area of cube is: %.3f",surface_area);
printf("\nVolume of cube is : %.3f",volume);
}
Volume of Cylinder
Volume of Cylinder
#include < stdio.h >
void main()
{
float vol,pie=3.14;
float r,h;
printf("ENTER THE VALUE OF RADIOUS :- ");
scanf("%f",&r);
printf("ENTER THE VALUE OF HEIGHT :- ");
scanf("%f",&h);
vol = pie * r * r * h;
printf("VOLUME OF CYLINDER IS :- %3.2f ",vol);
}
Volume of Sphere
Volume of Sphere
#include < stdio.h >
#include < math.h >
void main()
{
float radius,pie,volume;
pie=3.1416;
printf("Enter the radius:");
if(scanf("%f",&radius)==1)
{
volume=(4/3)*pie*pow(radius,3);
printf("The volume is :%6.2f",volume);
}
else
{
printf("error ,enter correct value");
}
}