File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ // Program to count the number of vowels present in a string. 
2+ 
3+ #include  <stdio.h> 
4+ 
5+ int  main () {
6+ 
7+  char  text [150 ];
8+ 
9+  // get input value for text using fgets() 
10+  fgets (text , sizeof (text ), stdin );
11+ 
12+  // variable to count number of vowels 
13+  int  vowels  =  0 ;
14+ 
15+  // loop to access each character of text 
16+  for  (int  i  =  0 ; text [i ] !=  '\0' ; ++ i ) {
17+ 
18+  // check if character at ith position is a vowel (lowercase or uppercase) 
19+  if  (text [i ] ==  'a'  ||  text [i ] ==  'A'  ||  text [i ] ==  'e'  ||  text [i ] ==  'E'  ||  text [i ] ==  'i'  ||  text [i ] ==  'I'  ||  text [i ] ==  'o'  ||  text [i ] ==  'O'  ||  text [i ] ==  'u'  ||  text [i ] ==  'U' ) {
20+  vowels ++ ;
21+  }
22+  }
23+ 
24+  // print the value of vowel 
25+  printf ("%d" , vowels );
26+ 
27+  return  0 ;
28+ }
                                 You can’t perform that action at this time. 
               
                  
0 commit comments