/* EXPERIMENT - */ /* AIM : DEMONSTRATION OF CASE STRUCTURE USING ILLUSTRATION OF AREA OF A TRIANGLE, CIRCLE, RECTANGLE AND SQUARE. */ /* PROGRAMMER : SHEKHAR A. SHERIKAR */ main() { int c; unsigned long float a,b; clrscr(); c=1; while(c!=0) { clrscr(); printf("\n\n\t\tThis program will help you to find the areas of geometric"); printf("\n\t\t figures specified in the following menu : "); printf("\n\n\t\t\t\tM A I N - M E N U"); printf("\n\n\t\t\t\t 1.Triangle\n\t\t\t\t 2.Circle"); printf("\n\t\t\t\t 3.Rectangle\n\t\t\t\t 4.Square"); printf("\n\n\t\t Type 0 to terminate the program and exit."); printf("\n\n\t\t Enter your choice from the above menu : "); scanf("%d",&c); switch(c) { case 1: printf("\n\n\t\t\tEnter the height of the triangle : "); scanf("%lf",&a); printf("\n\t\t\tEnter the base of the triangle : "); scanf("%lf",&b); printf("\n\n\t\t\t\t- A N S W E R -\n"); printf("\n\t\tArea of the triangle is %f square units.",0.5*a*b); printf("\n\n\t\t\tPress any key to continue..."); getch(); break; case 2: printf("\n\n\t\t\tEnter the radius of the circle : "); scanf("%lf",&a); printf("\n\n\t\t\t\t- A N S W E R -\n"); printf("\n\t\tArea of the circle is %f square units.",3.1428*a*a); printf("\n\t\t\t Press any key to continue..."); getch(); break; case 3: printf("\n\n\t\tEnter length of one side of the rectangle : "); scanf("%lf",&a); printf("\n\t\tEnter length of other side of the rectangle : "); scanf("%lf",&b); printf("\n\t\tArea of the rectangle is %f square units.",a*b); printf("\n\n\n\t\t\tPress any key to continue..."); getch(); break; case 4: printf("\n\n\t\tEnter the length of any one side of the square : "); scanf("%lf",&a); printf("\n\t\tThe area of the square is %f square units.",a*a); printf("\n\n\n\t\t\tPress any key to continue..."); getch(); break; case 0: clrscr(); printf("\n\n\n\n\n\n\n\t\t\t\tPROGRAM TERMINATED !"); printf("\n\n\n\t\t\tPress any key to return to source file..."); getch(); break; default:clrscr(); printf("\n\n\n\n\n\n\n\t\t\t\tINVALID INPUT ! "); printf("\n\n\n\t\t\t Press any key to try again..."); getch(); break; } } }