Area of triangle
#include < stdio.h >
void main()
{
int height, base;
float ans;
printf("Enter height and base");
scanf("%d %d",&height, &base);
ans= (1/2)*height*base;
printf("Area if triangle is %f",ans);
}
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
#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
#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
#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
#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
#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");
}
}
These are the Concept of C programming codes We'll be glad if you share your valuable information with us regarding this topic, then it will be a golden opportunity for all of us to improve ourselves and know more. Comment below!!
Comments
Post a Comment