Tuesday, 17 April 2018

Program To Input a Character From User And Check Enter Character Is Vowel or Consonant

/*program character is c or v*/
#include <stdio.h>
void main ()
{
char ch ;
clrscr () ;
printf ("/n Enter a character:") ;
scanf ("%c", & ch) ;
switch (ch)
{
case 'a';
printf ("/n vowel:") ;
break ;
case 'e';
printf ("/n vowel:") ;
break ;
case 'i';
printf ("/n vowel:") ;
break ;
case 'o';
printf ("/n vowel:") ;
break ;
case 'u';
printf ("/n vowel:") ;
break ;
default :
printf ("/n character is consonant:") ;
}
getch () ;
}


This is program to check input character from user is vowel or consonant . For check vowel or consonant we have switch statement . The syntax of switch statement is;

switch ( conditional variable )
{
case value 1 ;
statement ;
break ;
case value 2 ;
statement ; 
break ;
"
"
"
default :
statement :
}

So using this we can write the program for using different conditional program .







No comments:

Post a Comment

Featured post

Program to find Volume of given box in java

class volume { public static void main (String args []) { int l=5,b=6,h=10; int volume; volume=l*b*h; System.out.println (" vol...