Warning: The getchar() function accepts any character keyed in. This includes RETURN and TAB.
Output:
#inlcude <stdio.h>
main()
{
char answer;
printf("Would you like to know my name ?\n");
printf("Type Y for YES and N for NO: ");
answer = getchar(); /*...Reading a Character...*/
if(answer == 'Y' || answer == 'y')
printf("\n\n My name is Bond...,JAMES BOND \n");
else
print("\n\n You are good for nothing \n");
}
Would you like to know my name?
Type Y for YES and N for NO: Y
My name is Bond...,JAMES BOND
Would you like to know my name?
Type Y for YES and N for NO: N
You are good for nothing
0 comments:
Post a Comment