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

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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