Menu Close

Count the total number of vowels and consonants

Arif and Caleb both are friends. Both are planning to utilize the vacation holidays by learning a programming language. They learned the concept of the pointer and want to know the knowledge level.

So they decided to make a coding test for each other. 

Arif wrote a name in the paper, Caleb wants to count the vowels and consonants. Can you help Caleb?

Input:
The only input is a string

Output:
The number of vowels and consonants.
#include <stdio.h>
#include <string.h>
int main()
{
  int c1=0,c2=0;
  char str[150];
  char *pt;
  scanf("%s", str);
  pt=str;
  while(*pt!='\0')
  {
   if(*pt=='a'||*pt=='e'||*pt=='i'||*pt=='o'||*pt=='u'||*pt=='A'||*pt=='E'||*pt=='I'||*pt=='O'||*pt=='U'){
   c1++;
  }
   else c2++;
   pt++;
  }
  printf("vowels:%d\nconsonants:%d\n",c1,c2);
return 0;
}

INPUT_1:
FcukTheCode

OUTPUT:
vowels:4
consonants:7


INPUT_2:
Gambling

OUTPUT:
vowels:2
consonants:6


INPUT_3:
Retreat

OUTPUT:
vowels:3
consonants:4


ILLUSTRATION

Executed using gcc in terminal

Morae Q!