My Name: Om Chanlyta
Major: TMD
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
int a;
float b,h1,h2,v,pi=3.14159,r;
do{
printf("Please input value = ");
scanf_s("%d",&a);
switch(a)
{
case 1:
printf("Calculator volume of triangular pyramid\n");
printf("Please input value of base=");
scanf_s("%f",&b);
printf("Please input value of base height= ");
scanf_s("%f",&h1);
printf("please input value of pyramid height=");
scanf_s("%f",&h2);
v=(((b*h1)/2)*h2)/3;
printf("volume of traingular pyramid is=%f\n",v);
break;
case 2:
printf("Calculator volume of sphere\n");
printf("Please input value of radius=\n");
scanf_s("%f",&r);
v=((pi*r*r*r)*4)/3;
printf("volume of sphere is= %f\n",v);
break;
default:
printf("you do not type number 1 or 2 ");
break;
}
}while ((a!=1)&&(a!=2));
system ("pause");
return(0);
}
Below is video of How to Write a program that contains a calculation of the volume of a triangular pyramid and volume of a sphere:
This is my link :
No comments:
Post a Comment