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
|
#include <stdio.h>
void main()
{
int comp, one=0, two=0, three=0, four=0, five=0, choice, y;
printf("This is a program for selecting computations.");
do
{
one=0, two=0, three=0, four=0, five=0, choice, y;
printf("\n\nEnter the number of computations [0-5]:");
scanf("%i",&comp);
while (comp < 0 || comp > 5)
{
printf("\t%i is not a valid number.",comp);
printf("\n\nEnter the number of computations [0-5]:");
scanf("%i",&comp);
}
if (comp==0)
{
printf("\n\nEnd program\n");
}
for (int x = 0; x<comp; x++)
{
if (one==0)
{
printf("\n\t1 - Surface area of a cylinder");
}
if (two==0)
{
printf("\n\t2 - Surface area of a cone");
}
if (three==0)
{
printf("\n\t3 - Radius of a circle sector");
}
if (four==0)
{
printf("\n\t4 - Volume of a cylinder");
}
if (five==0)
{
printf("\n\t5 - Volume of a sphere");
}
printf("\n\nEnter a computation:");
scanf("%i",&choice);
if (choice==1 && one==0)
{
one++;
}
else if(choice==2 && two==0)
{
two++;
}
else if(choice==3 && three==0)
{
three++;
}
else if(choice==4 && four==0)
{
four++;
}
else if(choice==5 && five==0)
{
five++;
}
else
{
printf("%i is not a valid entry",choice);
x--;
}
}
}
while (comp!=0);
}
|