Showing posts with label Vowel. Show all posts
Showing posts with label Vowel. Show all posts

C Program To Check The Given Value Is Vowel

How to write a C Program To Check The Given Value Is Vowel in C Programming Language ?

Solution For C Program :

/*C Program To Check The Given Value Is Vowel*/

#include<stdio.h>
void main()
{
int flag = 0;
int ceckvowel(void);
printf("\nIn Main Control.\n Check Vowel.\n");
do
{
if(checkvowel() == 1)
{
printf("\nThe Given Character is a Vowel.");
flag = 1;
}
else
{
printf("\nTry Again...");
flag = 0;
}
}while(flag == 0);
}
int checkvowel(void)
{
char ch;
printf("\nEnter Any Character : ");
ch = getche();
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' ||
ch == 'I' || ch =='O' || ch =='U')
return 1;
else
return 0;
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Function to Check Vowel

How to write a C Function to Check Vowel in C Programming Language ?


Solution:

C Function to Check Vowel

int check_vowel(char a)
{
    if ( a >= 'A' && a <= 'Z' )
       a = a + 'a' - 'A';   /* Converting to lower case */

    if ( a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
       return 1;

    return 0;
}

C Program to Count Vowels, Consonants and Spaces in a string

C Program to count vowels, consonants and spaces in a string in C Programming Language ?

This C Program to Count Vowels, Consonants and Spaces in a string.
In this C Program the Sentence is Entered by the User and the C Program then Count Vowels, Consonants and Spaces in a String.

To Find:
  1. Total number of vowels entered.
  2. Total number of consonants entered.
  3. Total number of spaces entered.

Solution:

  1. #include<stdio.h>
  2. main()
  3. {
  4. int i,cons=0,vow=0,sp=0;
  5. char a[100];
  6. printf("Enter the sentence\n");
  7. gets(a);
  8. for(i=0;a[i]!='\0';i++)
  9. {
  10. if(a[i]=='a'||a[i]=='A')
  11. vow=vow+1;
  12. else if(a[i]=='e'||a[i]=='E')
  13. vow=vow+1;
  14. else if(a[i]=='i'||a[i]=='I')
  15. vow=vow+1;
  16. else if(a[i]=='o'||a[i]=='O')
  17. vow=vow+1;
  18. else if(a[i]=='u'||a[i]=='U')
  19. vow=vow+1;
  20. else if(a[i]==' ')
  21. sp=sp+1;
  22. else
  23. cons=cons+1;
  24. }
  25. printf("Total number of vowels entered = %d\n",vow);
  26. printf("Total number of consonants entered = %d\n",cons);
  27. printf("Total number of spaces entered = %d\n",sp);
  28. }