Thursday, March 3, 2016

C Program to count Vowels in a given string.

//C Program to count Vowels in a given string.

#include<stdio.h>
#include<string.h>
int main()
{
  char str[20]="AHMEDABAD";
  int i,cnt=0,len=0;
  
  len=strlen(str);
  
  for(i=0; i < len; i++)   
  {
      if( str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U')
          cnt++;      
  } 
  printf("Total vowels in given string: %d",cnt);
  return 0;
}
/*Output
Total vowels in given string: 4
*/

No comments:

Post a Comment