adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C and C++ to check a given character is vowel or consonant Using conditional operator.

Program in C and C++ to check a given character is vowel or consonant Using conditional operator.    


C
CPP
#include<stdio.h>
#include<ctype.h>
   int main()
     {
      char ch;
      printf("Enter a character:-");
      ch=getchar();
      ch=toupper(ch);
      if(ch>=65&&ch<=90)
        (ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')?printf("%c is vowel.",ch):printf("%c is consonant.",ch);
      else
        printf("%c is not alphabet.",ch);
     return 0;
 }
#include<iostream>
#include<ctype.h>
 using namespace std;
   int main()
     {
      char ch;
      cout<<"Enter a character:-";
      ch=getchar();
      ch=toupper(ch);
      if(ch>=65&&ch<=90)
        (ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')?printf("%c is vowel.",ch):printf("%c is consonant.",ch);
      else
        printf("%c is not alphabet.",ch);
     return 0;
 } 
Output:-








Related programs

  1. Program in C to check a given character is vowel or consonant Using switch case.
  2. Program in C to check a given character is vowel or consonant Using if else statement
  3. Program in C & C++ to count the number of vowels and consonants in a string Using switch case.
  4. Program in C & C++ to count the number of vowels and consonants in a string Using pointer

Post a Comment

0 Comments