C Tutorial
This c program is used to calculate the volume of a triangular prism based on user inputs bash and height.
Volume of a triangular prism = area of triangle × Heightor
Volume of a triangular prism = ((1/2) x Base x Height) × Height
// Finds volume of a triangular prism #include<stdio.h> void main() { float bash, height; float volume=0; printf("\nFinds volume of a triangle prism\n-------------------"); printf("\nEnter bash: "); scanf("%f", &bash); printf("\nEnter height: "); scanf("%f", &height); volume = ((float)1/(float)2)*bash*height*height; printf("Volume of a triangle prism is: %.2f", volume); }
Output:
$ cc volume-of-triangle-prism.c $ ./a.out Finds volume of a triangle prism ------------------- Enter bash: 8 Enter height: 9 Volume of a triangle prism is: 324.00
C Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page