Consonants in Range
The program must accept two lower case alphabets CH1 and CH2 as the input. The program must print all the consonants from CH1 to CH2 as the output.
Input Format:
The first line contains CH1 and CH2 separated by a space.
The first line contains CH1 and CH2 separated by a space.
Output Format:
The first line contains all the consonants from CH1 to CH2.
The first line contains all the consonants from CH1 to CH2.
Example Input/Output 1:
Input:
a z
Input:
a z
Output:
b c d f g h j k l m n p q r s t v w x y z
b c d f g h j k l m n p q r s t v w x y z
Explanation:
All the consonants (except the vowels) from a to z are printed as the output.
All the consonants (except the vowels) from a to z are printed as the output.
Example Input/Output 2:
Input:
v h
Input:
v h
Output:
v t s r q p n m l k j h
v t s r q p n m l k j h
Solution:-
#include<stdio.h>
#include <stdlib.h>
int isvowel(char ch)
{
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
return 1;
else
return 0;
}
int main()
{
char ch1,ch2;
scanf("%c %c",&ch1,&ch2);
if(ch1<ch2)
{
while(ch1<=ch2)
{
if(!isvowel(ch1))
{
printf("%c ",ch1);
}
ch1++;
}
}
else
{
while(ch1>=ch2)
{
if(!isvowel(ch1))
{
printf("%c ",ch1);
}
ch1--;
}
}
}
Comments
Post a Comment