Mega Code Archive

 
Categories / C / Beginners
 

Program for computing Area, Volume and Perimeter of Rrectangle using

function with looping #include <stdio.h> void inputoutput () { int comp,ans; clrscr (); printf ("choose please: 1=perimeter,2=area,3=volume] ?: "); scanf ("%d",&comp); if (comp==1) { int le, wi; printf ("Enter the length: "); scanf ("%d",&le); printf ("Enter the width: "); scanf ("%d",&wi); printf ("P=%d",perimeter(le,wi)); } else if (comp==2) { int le, wi; printf ("Enter the length: "); scanf ("%d",&le); printf ("Enter the width: "); scanf ("%d",&wi); printf ("A=%d", area(le,wi)); } else if (comp==3) { int length,width,height; printf ("Enter lenght: "); scanf ("%d",&length); printf ("Enter width: "); scanf ("%d",&width); printf ("Enter height: "); scanf ("%d",&height); printf ("V=%d",volume (length,width,height)); } else inputoutput (); printf (" Do you want to continue? [Yes=1/No=0]: "); scanf ("%d",&ans); if (ans==1) inputoutput (); else printf ("GOOD BYE"); } int perimeter (int l, int w) { int per; per=(l*2)+(w*2); return (per); } int area (int le, int wi) { int are; are=le*wi; return (are); } int volume (int length, int width, int height) { int vol; vol=(length*width*height); return (vol); } main () { clrscr (); inputoutput (); getch (); }