//C PROGRAM TO CALCULATE AREA OF A CIRCLE
#include <stdio.h>
#define PI 3.141
int main(){
float r, a;
printf("Radius: ");
scanf("%f", &r);
a = PI * r * r;
printf("%f\n", a);
return 0;
}
#define PI 3.141
int main(){
float r, a;
printf("Radius: ");
scanf("%f", &r);
a = PI * r * r;
printf("%f\n", a);
return 0;
}
//Write a c program to find the area of a triangle
#include<stdio.h>
#include<math.h>
#include<math.h>
int main(){
float a,b,c;
float s,area;
printf("Enter size of each sides of triangle");
scanf("%f%f%f",&a,&b,&c);
s = (a+b+c)/2;
area = sqrt(s*(s-a)*(s-b)*(s-c));
printf("Area of triangle is: %.3f",area);
return 0;
}
float a,b,c;
float s,area;
printf("Enter size of each sides of triangle");
scanf("%f%f%f",&a,&b,&c);
s = (a+b+c)/2;
area = sqrt(s*(s-a)*(s-b)*(s-c));
printf("Area of triangle is: %.3f",area);
return 0;
}
Sample output:
Enter size of each sides of the triangle: 2 4 5
Area of triangle is: 3.800
Area of triangle is: 3.800
//Write a c program to find the area of an equilateral triangle
#include<stdio.h>
#include<math.h>
#include<math.h>
int main(){
float a;
float area;
float area;
printf("Enter size of side of the equilateral triangle : ");
scanf("%f",&a);
scanf("%f",&a);
area = sqrt(3)/4*(a*a);
printf("Area of equilateral triangle is: %.3f",area);
return 0;
}
}
Sample output:
Enter size of side of the equilateral triangle: 5
Area of equilateral triangle is: 10.825
Area of equilateral triangle is: 10.825
//Write a c program to find the area of a right angled triangle
#include<stdio.h>
int main(){
float h,w;
float area;
float area;
printf("Enter height and width of the right angled triangle : ");
scanf("%f%f",&h,&w);
scanf("%f%f",&h,&w);
area = 0.5 * h * w;
printf("Area of right angled triangle is: %.3f",area);
return 0;
}
}
Sample output:
Enter height and width of the right angled triangle: 10 5
Area of right angled triangle is: 25.000
Area of right angled triangle is: 25.000
//Write a c program to find the area of a rectangle
#include<stdio.h>
int main(){
float l,w;
float area;
float area;
printf("Enter size of each sides of the rectangle : ");
scanf("%f%f",&l,&w);
scanf("%f%f",&l,&w);
area = l * w;
printf("Area of rectangle is: %.3f",area);
printf("Area of rectangle is: %.3f",area);
return 0;
}
}
Sample output:
Enter size of each sides of the rectangle: 5.2 20
Area of rectangle is: 104.000
Area of rectangle is: 104.000
//Write a c program to find the area of a trapezium
#include<stdio.h>
int main(){
float b1,b2,h;
float area;
float area;
printf("Enter the size of two bases and height of the trapezium : ");
scanf("%f%f%f",&b1,&b2,&h);
scanf("%f%f%f",&b1,&b2,&h);
area = 0.5 * ( b1 + b2 ) * h ;
printf("Area of trapezium is: %.3f",area);
return 0;
}
}
Sample output:
Enter the size of two bases and height of the trapezium: 5 8 3
Area of trapezium is: 19.500
Area of trapezium is: 19.500
//Write a c program to find the volume and surface area of a cube
#include<stdio.h>
int main(){
float a;
float surface_area,volume;
float surface_area,volume;
printf("Enter size of any side of a cube : ");
scanf("%f",&a);
scanf("%f",&a);
surface_area = 6 * (a * a);
volume = a * a * a;
volume = a * a * a;
printf("Surface area of cube is: %.3f",surface_area);
printf("\nVolume of cube is : %.3f",volume);
printf("\nVolume of cube is : %.3f",volume);
return 0;
}
}
Sample output:
Enter size of any side of a cube: 3
Surface area of cube is: 54.000
Volume of cube is: 27.000
Surface area of cube is: 54.000
Volume of cube is: 27.000
//Write a c program to find the volume and surface area of cuboids
#include<stdio.h>
int main(){
float w,l,h;
float surface_area,volume,space_ diagonal;
float surface_area,volume,space_
printf("Enter size of width, length and height of a cuboids : ");
scanf("%f%f%f",&w,&l,&h);
scanf("%f%f%f",&w,&l,&h);
surface_area = 2*(w*l + l*h + h*w);
volume = w * l * h;
space_diagonal = sqrt(w*w + l*l + h*h);
volume = w * l * h;
space_diagonal = sqrt(w*w + l*l + h*h);
printf("Surface area of cuboids is: %.3f",surface_area);
printf("\nVolume of cuboids is : %.3f",volume);
printf("\nSpace diagonal of cuboids is : %.3f",space_diagonal);
printf("\nVolume of cuboids is : %.3f",volume);
printf("\nSpace diagonal of cuboids is : %.3f",space_diagonal);
return 0;
}
}
Sample output:
Enter size of width, length and height of cuboids: 5 10 4
Surface area of cuboids is: 220.000
Volume of cuboids is: 200.000
Space diagonal of cuboids is: 11.874
Surface area of cuboids is: 220.000
Volume of cuboids is: 200.000
Space diagonal of cuboids is: 11.874
//Write a c program to find the volume and surface area of cylinder
#include<stdio.h>
#include<math.h>
#include<math.h>
int main(){
float r,h;
float surface_area,volume;
float surface_area,volume;
printf("Enter size of radius and height of a cylinder : ");
scanf("%f%f",&r,&h);
scanf("%f%f",&r,&h);
surface_area = 2 * M_PI * r * (r + h);
volume = M_PI * r * r * h;
volume = M_PI * r * r * h;
printf("Surface area of cylinder is: %.3f",surface_area);
printf("\nVolume of cylinder is : %.3f",volume);
printf("\nVolume of cylinder is : %.3f",volume);
return 0;
}
}
Sample output:
Enter size of radius and height of a cylinder: 4 10
Surface area of cylinder is: 351.858
Volume of cylinder is: 502.655
Surface area of cylinder is: 351.858
Volume of cylinder is: 502.655
//Write a c program to find the volume and surface area of cone
#include<stdio.h>
#include<math.h>
#include<math.h>
int main(){
float r,h;
float surface_area,volume;
float surface_area,volume;
printf("Enter size of radius and height of a cone : ");
scanf("%f%f",&r,&h);
scanf("%f%f",&r,&h);
surface_area = M_PI * r * (r + sqrt(r*r + h*h));
volume = (1.0/3) * M_PI * r * r * h;
volume = (1.0/3) * M_PI * r * r * h;
printf("Surface area of cone is: %.3f",surface_area);
printf("\nVolume of cone is : %.3f",volume);
printf("\nVolume of cone is : %.3f",volume);
return 0;
}
}
Sample output:
Enter size of radius and height of a cone: 3 10
Surface area of cone is: 126.672
Volume of cone is: 94.248
Surface area of cone is: 126.672
Volume of cone is: 94.248
//Write a c program to find the volume and surface area of sphere
#include<stdio.h>
#include<math.h>
#include<math.h>
int main(){
float r;
float surface_area,volume;
float surface_area,volume;
printf("Enter radius of the sphere : ");
scanf("%f",&r);
scanf("%f",&r);
surface_area = 4* M_PI * r * r;
volume = (4.0/3) * M_PI * r * r * r;
volume = (4.0/3) * M_PI * r * r * r;
printf("Surface area of sphere is: %.3f",surface_area);
printf("\nVolume of sphere is : %.3f",volume);
printf("\nVolume of sphere is : %.3f",volume);
return 0;
}
}
Sample output:
Enter radius of the sphere: 5
Surface area of sphere is: 314.159
Volume of sphere is: 523.599
Surface area of sphere is: 314.159
Volume of sphere is: 523.599
No comments:
Post a Comment