I tried test the code seperately. If I only leave one scanf on in the program , it would work and go through the switch statement. However, once I put two scanf function in the program the program will only read the first one and auto skipped to default. Can someone help me fix this please?
#include <stdio.h>
//#include <conio.h>
#include <math.h>
#include <curses.h>
int main() {
double baseLength, height;
char letter;
printf("Enter the base length and the height of the square pyramid in centermeter please.\n");
scanf("%lf%lf",&baseLength,&height);
printf("%lf%lf\n",baseLength,height);
printf("P. Calculate and display the perimeter of the base of the square pyramid\n");
printf("A. Calculate and display the surface area of the square pyramid\n");
printf("V. Calculate and display the volume of the square pyramid\n");
printf("Please input P / A / V to choose the desire calculation\n");
scanf("%c",&letter);
switch(letter)
{
case 'P':
case 'p':
printf("P");
break;
case 'A':
case 'a':
printf("A");
break;
case 'V':
case 'v':
printf("V");
break;
default:
printf("Invalid Input");
getch();
return 0;
}
getch();
return 0;
}