I am currently trying to make code for a calculator that will calculate the area of a
circle
,cube
, orsquare
, depending on which integer the user enters in the beginning, then prompt for the measurements, etc.
I want the user to choose between1
,2
, or3
.
My current code:
#include <stdio.h>
#include <math.h>
int main(void){
int shape;
printf("\nArea calculation\n(1) Square\n(2) Cube \n(3) Circle \nPlease make a selection");
scanf("%d", &shape);
else{
printf("\nIncorrect Choice");
}
return 0;
}
My question is:
- How can I make an error message pop up if they haven't entered that info?
- How I can make it loop and ask the same question again if they enter something other than
1
,2
,3
. - How do I make it so if the user enters something line:
99
then the program shuts off?