forked from CodXCrypt/C-Programs-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Counting Vowels and Consonants CodXCrypt#63
- Loading branch information
1 parent
fbefe85
commit f06bef5
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |