i try to ask the user after a process of calculation that if he wants to do more calculation for that i use do while loop but for some reason it should first calculate area then it should ask user if he wants to calculate more the it should repeat or exit
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
int option;
float Area, Radius, Length, Width, Height, Circumference, Volume;
char select;
do {
printf("\nPlease select the option\n");
printf(
"1.Area and Circumference of circle \n2.Area of rectangle \n3.Area of "
"triangle \n4.Volume of sphere");
printf("\nEnter your selection : ");
scanf("%i", &option);
system("cls");
switch(option) {
case 1:
printf("Enter the radius of the circle : ");
scanf("%f", &Radius);
Area = 3.14159 * pow(Radius, 2);
Circumference = 2 * 3.14159 * Radius;
system("cls");
printf("Area of circle is %f Circumference of circle is %f", Area,
Circumference);
break;
case 2:
printf("Enter length of the rectangle :");
scanf("%f", &Length);
system("cls");
printf("Enter width of the rectangle :");
scanf("%f", &Width);
system("cls");
Area = Length * Width;
printf("The Area of rectangle is %f", Area);
break;
case 3:
printf("Enter the height of triangle :");
scanf("%f", &Height);
system("cls");
printf("Enter the lenght of triangle :");
scanf("%f", &Length);
system("cls");
Area = Height * Length / 2;
printf("The area of the triangle is %f", Area);
break;
case 4:
printf("Enter the radius of the sphere :");
scanf("%f", &Radius);
system("cls");
Volume = 4 * 3.14159 * pow(Radius, 3) / 3;
printf("The surface area of the sphere is %f", Volume);
break;
default:
printf("Invalid option\t\t");
break;
}
printf("\nDo you want to do another calculation");
scanf("%c", &select);
} while(select == 'y');
}
does not work