Hello,
I have a code which uses getchar().
[CODE=c]#include<stdio. h>
int main()
{
char ch;
ch = getchar();
if(ch == 'Y')
{
printf("Beautif ul World\n");
}
else
{
printf("Cruel World\n");
}
ch = getchar();
if(ch == 'N')
{
printf("Second getchar\n");
}
else
{
printf("Second getchar else part\n");
}
return 0;
}[/CODE]
and the o/p is
Beautiful World
Second getchar else part
the second getchar() is not waiting to enter the character from the user....
I have a code which uses getchar().
[CODE=c]#include<stdio. h>
int main()
{
char ch;
ch = getchar();
if(ch == 'Y')
{
printf("Beautif ul World\n");
}
else
{
printf("Cruel World\n");
}
ch = getchar();
if(ch == 'N')
{
printf("Second getchar\n");
}
else
{
printf("Second getchar else part\n");
}
return 0;
}[/CODE]
and the o/p is
Beautiful World
Second getchar else part
the second getchar() is not waiting to enter the character from the user....
Comment