Skip to content

Commit

Permalink
Added Counting Vowels and Consonants CodXCrypt#63
Browse files Browse the repository at this point in the history
  • Loading branch information
ishitakapoor26 committed May 26, 2021
1 parent fbefe85 commit f06bef5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions CountingVowelsNC.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>
int main()
{
char str[100];
char *p;
int vCount=0,cCount=0;

printf("Enter any string: ");
fgets(str, 100, stdin);

//assign base address of char array to pointer
p=str;

//'\0' signifies end of the string
while(*p!='\0')
{
if(*p=='A' ||*p=='E' ||*p=='I' ||*p=='O' ||*p=='U'
||*p=='a' ||*p=='e' ||*p=='i' ||*p=='o' ||*p=='u')
vCount++;
else
cCount++;
//increase the pointer, to point next character
p++;
}

printf("Number of Vowels in String: %d\n",vCount);
printf("Number of Consonants in String: %d",cCount);
return 0;
}

0 comments on commit f06bef5

Please sign in to comment.