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
|
switch(choice)
{
case 1:
{while(1) {
printf("Distance Travelled Submenu\n");
printf("==================================\n");
printf("(A) Given Vi, a, t\n");
printf("(D) Back to Main Menu\n\n");
printf("Enter choice: ");
flushall();
scanf("%c", &choice1);
switch(choice1)
{
case 'a' :
case 'A' : printf("Enter Vi: ");
scanf("%f", &Vi);
printf("Enter a: ");
scanf("%f", &acceleration);
printf("Enter t: ");
scanf("%f", &t);
distrav=(acceleration*t*t)/2+Vi*t;
if(distrav<0)
{
printf("Towards left.\n");
}
if(distrav>0)
{
printf("Towards right.\n");
}
if(distrav<0)
{
distrav=-distrav;
}
printf("Distance travelled: %.2f m\n", distrav); break;
case 'D' :
case 'd' : break;
default : printf ("Enter Valid response.\n\n"); continue;
}break;
}break;
}
case 2:
{while(1)
{
printf("Initial Velocity Submenu\n");
printf("==================================\n");
printf("(A) Given d, a, t\n");
printf("(D) Back to Main Menu\n\n");
printf("Enter choice: ");
flushall();
scanf("%c", &choice2);
switch(choice2)
{
case 'a' :
case 'A' :printf("Enter d: ");
scanf("%f", &distrav);
printf("Enter a: ");
scanf("%f", &acceleration);
printf("Enter t: ");
scanf("%f", &t);
Vi=(distrav/t)-((acceleration*t)/2);
if(Vi<0)
{
printf("Towards left.\n");
}
if(Vi>0)
{
printf("Towards right.\n");
}
if(Vi<0)
{
Vi=-Vi;
}
printf("Initial Velocity: %.2f m/s\n", Vi); break;
case 'd' :
case 'D' : break;
class="quote">class="qd">default : printf ("Enter Valid response.\n\n"); continue; |
}break;
}break;
}
default : printf ("Enter Valid response.\n\n"); menu();
}
|