Q:

write program in c to calculate volume using function

0

write program in c to calculate volume using function

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

#include<stdio.h>
#include<conio.h>
float pi=3.14;
int cube(int a);
int cuboid(int l,int w,int h);
int sphere(int r);
void main()
{
	int i,j,k,l,d,V;
	printf("Find volume of some shapes\n");
	printf("\n CUBE\n");
	cube(i);
	printf("\n CUBOID\n");
	cuboid(j,k,l);
	printf("\n SPHERE\n");
	sphere(d);
}
   int cube(int a)
   {
   	printf("Enter side of the cube\n");
   	scanf("%d",&a);
   	printf("Volume of cube is: %d\n",a*a*a);
   return 0;
   }
   int cuboid(int l,int w,int h)
  {
  	printf("Enter length of cuboid\n");
  	scanf("%d%d%d",&l,&w,&h);
  	printf("Volume is cuboid: %d\n",l*w*h);
  	return 0;

	 }   
	 int sphere(int r)
	 {
	 	printf("Enter radius of sphere\n");
	 	scanf("%d",&r);
	 	printf("Volum of sphere is:%f",4/3*pi*r*r*r);
	 	return 0;
	
	 	
	 }

Output:

Find volume of some shapes

 CUBE
Enter side of the cube
2
Volume of cube is: 8

 CUBOID
Enter length of cuboid
2 3v4   4
Volume is cuboid: 24

 SPHERE
Enter radius of sphere
2
Volum of sphere is:25.120001

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programming Exercises With Solutions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a program in c to search an element form arr... >>
<< Write a c program using switch case to calculate t...