Did you use  lowercase y as input .
If you have used upper case Y this will work once....

On 28 Mar 2007 22:05:11 -0700, shahwalishaik <[EMAIL PROTECTED]> wrote:
> hi there,
>
> the book i follow for C language shows that the following program is
> correct. but when i complie and run, it is giving odd results. the
> problem is it is running just once, even if 'y' is being entered for
> the second time. help me find the bug
>
>
> /*execution of a loop unknown number of times*/
>
> main()
>  char another='y';
>  int num;
>
>  while(another=='y')
> {
>  printf("enter a number");
>  scanf("%d",&num);
>  printf("square of %d id %d", num, num*num);
>  printf("want to enter another number? y/n");
>  scanf("%c",&another);
> }
> getch();
> }
>
>
>
>

Reply via email to