Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C Language using \"#Include <stdio.h>\". Write a program to produce a cube. I

ID: 2268275 • Letter: I

Question

In C Language using "#Include <stdio.h>".

Write a program to produce a cube. Input from the user the length of a side. Compute the area of the base of the cube, the surface area, and the volume. Display these values to the user Write a program to produce a cylinder. Input from the user the radius and height of the desired cylinder. Compute the area of the base, the surface area, and the volume. Display these values to the user Write a program to produce a square pyramid. Input the length of the side of the base and the height. Compute the area of the base, the surface area, and the volume. Display these values to the user.

Explanation / Answer

//Program for cube
#include <stdio.h>

int main()
{
float length;
//Program to produce the cube
printf("Enter the length of a side of cube ");
scanf("%f",&length);
printf("The area of base of cube is %f ", length*length);
printf("The surface area of the cube is %f ",6*length*length);
printf("The volume of the cube is %f ",length*length*length);
  
}

//Program for cylinder

#include <stdio.h>

int main()
{
float radius, height;
float pi = 3.14; //constant
printf("Enter the radius and height of the cylinder ");
scanf("%f %f",&radius,&height);
printf("The area of base of cylinder is %f ",(pi*radius*radius));
printf("The surface area of the cylinder is %f ",(2*pi*radius*(radius+height)));
printf("The volume of cylinder is %f ",(pi*radius*radius*height));

return 0;
}

//Program for square pyramid
#include <stdio.h>

int main()
{
float length,height,surfacearea,volume,base_area;
float pi = 3.14; //constant
printf("Enter the side length base and height of the square pyramid ");
scanf("%f %f",&length,&height);
printf("The side length of base is %f and height is %f ",length,height);
base_area = length*length;
printf("The area of base of pyramid is %f ",base_area);
surfacearea = length*length + 2*length*sqrt(((length*length)/4)+height*height);
printf("The surface area of the pyramid is %f ",surfacearea);
volume = length*length*height/3;
printf("The volume of pyramid is %f ",volume);

return 0;
}