Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Define a structure for a rectangular prism (name the structure prism), which has

ID: 3654509 • Letter: D

Question

Define a structure for a rectangular prism (name the structure prism), which has the following members: length, width, height, surface area and volume of the prism. Write a C program that has a main and one function. In main, length, width and height of a rectangular prism are input from keyboard (scanf), call function area, print the area. In function area(prismPtr), the surface area is calculated

Explanation / Answer

#include struct prism { float length; float width; float height; float area; float volume; }; float area(struct prism *prt); int main() { struct prism p; printf("Enter lenght, width and hight of the prism "); scanf("%f %f %f",&p.length, &p.width, &p.height); p.area=area(&p); printf("Surface area of prism is : %f", p.area); return 0; } float area( struct prism *ptr) { ptr->area=2*(ptr->length*ptr->width+ptr->length*ptr->height+ptr->width*ptr->height); return ptr->area; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote