C Program to Find Volume and Surface Area of a Cube

C Program to Find Volume and Surface Area of a Cube

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

Recommended C Programs

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *