[C]Do loop prob 05-13-2011, 09:58 PM
#1
Hey! So, I have another noob question, I'm learning the DO loop... well... I have this code:
well... when I execute the code, this happens:
=> I'm asked to enter a number
=> A square of the number is printed
=> It asks me if I want to enter another number
=> The program exits ...
Well... where is the prob? Thanks!!!
Code:
main() {
char another;
int num;
do
{
printf("\nEnter a number: ");
scanf("%d", &num);
printf("Square of %d is %d", num, num * num);
printf("\nWant to enter another number y/n? ");
scanf("%c",&another);
}while(another == 'y');
}
well... when I execute the code, this happens:
=> I'm asked to enter a number
=> A square of the number is printed
=> It asks me if I want to enter another number
=> The program exits ...
Well... where is the prob? Thanks!!!
Staff will never ever ask you for your personal information.
We know everything about you anyway.
We know everything about you anyway.