C Program to count Vowels in a string using Pointer

 

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
void main()
{
char sk[20], *sr;
int count=0;
clrscr();
printf("Enter a String: ");
gets(sk);
sr=sk;
while(*sr!='\0')
{
switch(toupper(*sr))
{
case 'A' :
case 'E' :
case 'I' :
case 'O' :
case 'U' :
count++;
break;
}
sr++;
}
printf("Number of Vowels is : %d", count);
getch();
}

 

Output:

C Program to count Vowels in a string using Pointer