Do While Menu

Well,the thing is I needed to do a do-while menu and it doesn't work correctly, although I don't know where I got wrong. Can anyone help me?Thank you!! This is the code:

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
  #include <stdio.h>

int main(void)
{
	char option;
    float b1;
    float h1;
    float s;
    float r;
    float b2;
    float h2;
    float area_rect;
    float area_sq;
    float area_circ;
    float area_tri;
    
    
    do {
        printf("\n\n********************************************\n");
        printf("   Choose an Option: \n");
        printf(" R. Type to calculate the area of a rectangle \n");
        printf(" S. Type to calculate the area of a square \n");
        printf(" C. Type to calculate the area of a circle \n");
        printf(" T. Type to calculate the area of a triangle \n");
        printf(" E. Type to exit the program \n");
        printf("********************************************\n");
        printf("Introduce option: ");
        scanf("%c", &option);
    
        switch (option) {
            case 'R':
                printf("\nUser has chosen R: calculate the area of a rectangle\n");
                printf("Base of the rectangle: ");
                scanf("%f", &b1);
                printf("Height of the rectangle: ");
                scanf("%f", &h1);
            
                area_rect = b1*h1;
            
                printf("The result is: %.2f", area_rect);
            break;
            
            case 'S':
                printf("\nUser has chosen S: calculate the area of a square\n");
                printf("Side of the square: ");
                scanf("%f", &s);
            
                area_sq = s*s;
            
                printf("The result is: %.2f", area_sq);
            break;
            
            case 'C':
                printf("\nUser has chosen C: calculate the area of a circle\n");
                printf("Radius of the circle: ");
                scanf("%f", &r);
            
                area_circ = 3.14*r*r;
            
                printf("The result is: %.2f", area_circ);
            break;
            
            case 'T':
                printf("\nUser has chosen T: calculate the area of a triangle\n");
                printf("Base of the triangle: ");
                scanf("%f", &b2);
                printf("Height of the triangle: ");
                scanf("%f", &h2);
            
                area_tri = b2*h2/2;
            
                printf("The result is: %.2f", area_tri);
            break;
            
            case 'E':
                printf("\nUser has chosen to exit\n ");
                printf("\nThank you, user. See you soon\n");
            break;
            
            default: printf("\n\nError, check the option chosen please\n");
        }
    } while (option != 'E');
        
return 0;	
}




Topic archived. No new replies allowed.