Ticker

6/recent/ticker-posts

Alphabet or not Program



Program to check whether a character is alphabet or not - 


  • If-else
#include <stdio.h>

int main()
{ char ch;
    printf("Enter the character ");
    scanf(" %c",&ch);
    if((ch>= 'A'&& ch<='Z') || (ch>='a'&& ch<='z'))
      printf("Alphabet");
    else 
    printf("Enter valid input.");
    return 0;
}

Output -

Enter the character f
alphabet

  • Conditional - 
#include <stdio.h>

int main()
{ char ch;
    printf("Enter the character ");
    scanf(" %c",&ch);
   (ch>= 'A'&& ch<='Z') || (ch>='a'&& ch<='z')?
    printf("Alphabet") :
    printf("Enter valid input.");
    return 0;
}

Output -

Enter the character f
alphabet

Post a Comment

0 Comments