Vowels Count

 Coding Problem Keys 

 Vowels Count 

 Problem Statement 

The program must accept a string S with space as the input. The program must print the number of vowels in S as the output.

 Boundary Condition(S) 

1 <= Length of String <=1000

 Input Format 

The first line contains string.

 Output Format 

The first line contains the count of vowels in string.

 Example Input/Output 1 

 Input 

daEmon

 Output 

3

 Example Input/Output 2 

 Input 

hello

 Output 

2

 Example Input/Output 3 

 Input 

editable

 Output 

4

 Note: Max Execution Time Limit: 4000 millisecs 

 Solution 

 Programming Language: C Language 

#include <stdio.h>

int countVowels(char s[1001]){
    int c=0;
    for(int i=0;s[i]!='\0';i++){
        char ch=tolower(s[i]);
        if(ch=='a'||ch=='e'||ch=='o'||ch=='i'||ch=='u') c++;
    }
    return c;
}
// Published By PKJCODERS
int main()
{
    char str[1001];
    scanf("%s",str);
    printf("%d", countVowels(str));
}

 Alter 

#include <stdio.h>
#include <stdlib.h>
int main() {
    char a[1001];
    scanf("%[^\n]",a);
    int s=0,i=0;
    for(i=0;i<strlen(a);i++){
        a[i]=tolower(a[i]);
        if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'){
            s++;
        }
    }
    printf("%d",s);
}
// Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Unique Characters

Reverse Array

Largest Possible N - Divisible by 4

Function samePositionBitCount - CTS Pattern

Snakes and Ladders

String - Reverse Vowels