I do not understand how to pause my display loop. I thought the second scanf would do the job, but it doesn't. Here is the code
Code:
int main ()
{
int op1; // user input operand1
int op2; // user input operand2
char operator; // user input operator
int result; // answer for calculation
int status; // open or close calculator program
for (status = 0 ;status !='q'; )
{
printf("\n\t\tCALCULATOR\n\n");
printf(" Make your selection by entering 2 numbers\n");
printf(" and an operator as shown in the form below\n\n");
printf("\ti1 + i2 i1 plus i2\n");
printf("\ti1 - i2 i1 minus i2\n");
printf("\ti1 * i2 i1 multiply times i2\n");
printf("\ti1 / i2 i1 divided by i2\n");
printf("\ti1 ^ i2 i1 to the power i2\n");
printf("\ti1 G i2 the greatest common divisor (gcd) of i1 and i2\n");
printf("\ti1 L i2 the least common multiple (lcm) of i1 and i2\n");
printf("\ti1 R i2 the square root of one quarter of the sum of i1 and i2\n");
printf("\ti1 Q i2 quit the calculator program\n\n");
printf(" The above menu lists available operations on the left and a brief explanation\n");
printf(" on the right. Use the format of the operations on the left to enter a formula\n");
printf(" \n");
printf("Type NUMBER OPERATOR NUMBER and press RETURN:\n");
scanf("%d %c %d", &op1, &operator, &op2);
switch (operator)
{
case '+': result = plus(op1,op2); break;
case '-': result = minus(op1,op2); break;
case '*': result = multi(op1,op2); break;
case '/': result = divd(op1,op2); break;
case '^': result = powr(op1,op2); break;
case 'g': result = gcd(op1,op2); break;
case 'l': result = lcm(op1,op2); break;
case 'r': result = qtrsumroot(op1,op2); break;
default: printf("Please re-enter your request\n"); break;
}
printf("your formula is %d %c %d. The answer is %d\n\n", op1, operator, op2, result);
printf("Press any key to reset calculator. Press Q to quit.\n");
scanf("%c". &status);
}
}
thanks for any insight.
Keith