C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Use of getchar function

Posted By: Rainart Fischer     Category: C Programming     Views: 6618

Program that provides the use of getchar function.

Code for Use of getchar function in C Programming

#include   <stdio.h>                                        
 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\nMy name is BUSY BEE\n"); else printf("\n\nYou are good for nothing\n"); } Output Would you like to know my name? Type Y for YES and N for NO: Y My name is BUSY BEE Would you like to know my name? Type Y for YES and N for NO: n You are good for nothing

Didn't find what you were looking for? Find more on Use of getchar function Or get search suggestion and latest updates.

Rainart Fischer
Rainart Fischer author of Use of getchar function is from Frankfurt, Germany.
View All Articles

Related Articles and Code:

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!