Thursday, March 3, 2016

C Program to count Consonant 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 Consonants in given string: %d",cnt);
  return 0;
}
/*Output
Total Consonants in given string: 5
*/

No comments:

Post a Comment