C program to find volume and surface area of Cube; Through this tutorial, we will learn how to find or calculate volume and surface area of Cube using standard formula, function and pointer in c programs.
Programs to Find Volume and Surface Area of Cube in C
To find or calculate volume and surface area of Cube using standard formula, function and pointer in c:
- C Program to Find Volume and Surface Area of Cube using Standard Formula
- C Program to Find Volume and Surface Area of Cube using Function
- C Program to Find Volume and Surface Area of Cube using Pointer
C Program to Find Volume and Surface Area of Cube using Standard Formula
#include<stdio.h>
int main()
{
float side,area;
printf("enter side of cube: ");
scanf("%f",&side);
area=side*side*side;
printf("Volume and Surface Area of a Cube: %f\n",area);
return 0;
}
The output of the above c program; as follows:
enter side of cube: 10 Volume and Surface Area of a Cube: 1000.000000
C Program to Find Volume and Surface Area of Cube using Function
#include<stdio.h>
float area(float s)
{
return (s*s*s);
}
int main()
{
float v,s;
printf("enter side of the cube: ");
scanf("%f",&s);
s=area(s);
printf("Volume and Surface Area of a Cube: %f\n",s);
return 0;
}
The output of the above c program; as follows:
enter side of the cube: 112 Volume and Surface Area of a Cube: 1404928.000000
C Program to Find Volume and Surface Area of Cube using Pointer
#include<stdio.h>
void area(float *s,float *v)
{
*v=(*s)*(*s)*(*s);
}
int main()
{
float s,v;
printf("enter side: ");
scanf("%f",&s);
area(&s,&v);
printf("Volume and Surface Area of a Cube: %f\n",v);
return 0;
}
The output of the above c program; as follows:
enter side: 15 Volume and Surface Area of a Cube: 3375.000000