Now it gives following output, but it is not the expected output.
I still could not find what the problem is.
Please enter the input character :
y
You have entered: y (decimal 121)
HIIIIIIIII
Please enter the input character :
You have entered:
(decimal 10)
Please enter the input character :
y
You have entered: y (decimal 121)
HIIIIIIIII
Please enter the input character :
You have entered:
(decimal 10)
Please enter the input character :
y
You have entered: y (decimal 121)
HIIIIIIIII
On Dec 5, 1:29 am, "Mike Wahler" <mkwah...@mkwahler.netwrote:
<j.smit...@googlemail.comwrote in message
news:3f**********************************@v4g2000h sf.googlegroups.com...
Hi everyone,
I wanted to run the following loop,
and enter y everytime (I expected that it will ask
me to enter y for 5 time), but just after 3 times program terminates.
what is the error??
#include <stdio.h>
int main ()
{
char ch;
int j=0;
for (j ; j<5 ; j++)
{
printf("Please enter the input character :\n\n");
scanf("%c", &ch);
printf("You have entered : %c \n\n" , ch);
Change the above line to:
printf("You have entered: %c (decimal %d) \n", ch, (int)ch);
and run it again. Look carefully at the results.
if (ch == 'y' || ch == 'Y')
printf("HIIIIIIIII \n");
}
return 0;
}
-Mike