Default case not working

Hello, Good day.

I am working on a simple calculator involving switch cases.
But i met with a problem which is only the default case for the first switch case works and others doesn't seems to work.

Can somebody help me please?

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(); }



The quoted part is the default case that is not working.
Is there a fix to this?
Thank you
Last edited on
what makes you think that it doesn't work?
The statement doesn't print out.
Topic archived. No new replies allowed.