Read one letter and check its value - C Data Type

C examples for Data Type:char

Description

Read one letter and check its value

Demo Code

#include <stdio.h> 
int main()// ww w  .  ja v  a 2  s .  c o  m
{ 
   char cResponse = '\0'; 
   printf("Enter the letter A: "); 
   scanf("%c", &cResponse); 

   if ( cResponse == 'A' ) 
      printf("\nCorrect response\n"); 
   else 
      printf("\nIncorrect response\n"); 
}

Result


Related Tutorials