1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#define pi 3.1416
main()
{
int ch=0,chc=0,cht=0,chs=0;
float r=0,C=0,Ac=0,Vc=0,S=0,Ps=0,As=0,Vs=0,Pt=0,b=0,h=0,At=0,Vt=0;
do{
system("cls");
printf("Geometric Formulas");
printf("\n1. Circle");
printf("\n2. Square");
printf("\n3. Triangle");
printf("\n4. Exit");
printf("\n \n");
printf("\nChoice: ");
scanf("%d", &ch);
switch(ch){
case 1: //circle
do{
system("cls");
printf("Circle");
printf("\n1. Circumference");
printf("\n2. Area");
printf("\n3. Volume");
printf("\n4. Exit");
printf("\n \n");
printf("\nChoice: ");
scanf("%d", &chc);
switch(chc){
case 1: //Circumference
system("cls");
printf("This Computes the circumference of a circle");
printf("\n\n");
printf("Enter Radius");
scanf("%f", &r);
C=2*pi*r;
printf("The Circumference of a circle with radius %f is %f",r,C);
system("Pause");
break;
case 2: //Area
system("cls");
printf("This Computes the Area of a circle");
printf("\n\n");
printf("Enter Radius");
scanf("%f", &r);
Ac= 2*pi*r*r;
printf("The Area of a circle with radius %f is %f",r,Ac);
system("Pause");
break;
case 3: //Volume
printf("This Computes the Volume of a Sphere");
printf("\n\n");
printf("Enter Radius");
scanf("%f",&r);
Vc= (4/3)*(pi*r*r*r);
printf("The Volume of a sphere with radius %f is %f",r,Vc);
break;
case 4: //exit from chc
return main();
default:
printf("The Operation cannot be done");
break;
}while (chc!=4);
break;
case 2: //square
do{
system("cls");
printf("Square");
printf("\n1. Perimeter");
printf("\n2. Area");
printf("\n3. Volume");
printf("\n4. Exit");
printf("\n \n");
printf("\nChoice: ");
scanf("%d", &chs);
switch(chs){
case 1: //Perimeter Square
system("cls");
printf("This Computes the Perimeter of a Square");
printf("\n\n");
printf("Enter Length of Side");
scanf("%f", &S);
Ps=4*S;
printf("The Perimeter of a Square with side %f is %f",S,Ps);
system("Pause");
break;
case 2: //Area of A Square
system("cls");
printf("This computes the perimeter of a Square");
printf("\n\n");
printf("Enter Length of Side");
scanf("%f",&S);
As= S*S;
printf("The Area of a Square with side %f is %f",S,As);
system("Pause");
break;
case 3: //Volume of A Cube
system("cls");
printf("This computes the volume of a Cube");
printf("\n\n");
printf("Enter Length of Side");
scanf("%f",&S);
Vs= (S*S*S);
printf("The volume of a cube with side %f is %f", S,Vs);
system("Pause");
break;
case 4: //exit from chs
return main();
default:
printf("The Operation cannot be done");
break;
}
}while(chs!=4);
case 3: //triangle
do{
system("cls");
printf("Triangle");
printf("\n1. Perimeter");
printf("\n2. Area");
printf("\n3. Volume");
printf("\n4. Exit");
printf("\n \n");
printf("\nChoice: ");
scanf("%d", &cht);
switch(cht){
case 1: //Perimeter of a Triangle
system("cls");
printf("This computes the Perimeter of a Triangle");
printf("\n\n");
printf("Enter Length of Side");
scanf("%f",S);
Pt= S+S+S;
printf("The Perimeter of a triangle with side %f is %f",S,Pt);
system("Pause");
break;
break;
case 2: // Area of a Triangle
system("cls");
printf("This computes the Area of a triangle");
printf("\n\n");
printf("Enter Base");
scanf("%f",&b);
printf("Enter Height");
scanf("%f",&h);
At= ((b*h)/2);
printf("The Area of a Triangle with Base %f and Height %f is %f",b,h,At);
system("Pause");
break;
break;
case 3: // Volume
system("cls");
printf("This computes the volume of a pyramid");
printf("\n\n");
printf("Enter Area of the base of the Pyramid");
scanf("%f",b);
printf("Enter Height of the Pyramid");
scanf("%f",h);
Vt= b*h;
printf("The Volume of the pyramid with Base Area of %f and Heigh of %f is %f",b,h,Vt);
system("Pause");
break;
break;
case 4: //exit from cht
return main();
default:
printf("The Operation cannot be done");
}
case 4: //exit from ch
}while(ch!=4);
system("PAUSE");
return 0;
}
|