Hope someone could help me on this one, thanks in advanced!
My objective is to repeat an input until the user hit/press the letter 'N'
But the problem is when it comes to the part of answering the question:
"Add Another Number? [Y/N]"
the program stops!
Here's my faulty code: :(
#include<stdio.h>
#include<conio.h>
int main()
{
int num1, num2, total;
char ans;
clrscr();
do {
printf("Enter first number: ");
scanf("%d", &num1);
printf("Enter second number: ");
scanf("%d", &num2);
total = num1 + num2;
printf("\nTotal is: %d \n", total);
printf("\nAdd another number? [Y/N]: ");
scanf("%c",&ans);
} while (ans != 'N');
getch();
return(0);
}
Thanks again to all!