C program to find the volume of a cube - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Friday, June 14, 2019

C program to find the volume of a cube


In this tutorial we will find the volume of a cube.Whenever we calculate the volume of ​​a cube, then we should know its edge for it.

Solution

  • In this program we will use edge of a cylinder so we will take two variables as a and volume.
  • We declared these variables in float data type.
  • Then we will enter the value of edge of a cube.
  • We use a logic as volume=a*a*a;
  • When we use this statement the value of edge multiplication of a cube will be store in volume variable.
  • Then we will print the volume of a cube.

C program code


#include<stdio.h>
#include<conio.h>
void main()
{
float a;
float volume;
clrscr();

printf("\n Enter the edge of a cube=");
scanf("%f",&a);

volume=a*a*a;

printf("\n The volume of a cube is=");
printf("%f",volume);
getch();
}


Output 1:



Output 2:




Whenever we calculate the volume of ​​a cube, then we should know its edge for it.In the first,we determine the edge then multiply in three times.


No comments:

Post a Comment