Input
Enter a string : playwithcoding
Output
Number of vowel = 4
Step 1: START
Step 2: Declare a variable count=0;
Step 3: Enter a string as an input.
Step 4: Check each character of the string:
if ch[i]=A,E,I,O,U or a,e,i,o,u
count++;
Step 5: Print count
Step 6: END
/* Count number of vowel */
#include <stdio.h>
int main()
{
int count=0;
char str[10];
printf(" Enter a character : ");
scanf("%s",str);
for(int i=0;str[i];i++)
if(str[i]=='A'||str[i]=='a'||str[i]=='E'||str[i]=='e'||str[i]=='I'||str[i]=='i'||str[i]=='O'||str[i]=='o'||str[i]=='U'||str[i]=='u')
count++;
printf(" number of vowel present in %s = %d",str,count);
return 0;
}
/* Count number of vowel */
#include <iostream>
using namespace std;
int main()
{
int count=0;
char str[10];
cout<<" Enter a character : ";
cin>>str;
for(int i=0;str[i];i++)
if(str[i]=='A'||str[i]=='a'||str[i]=='E'||str[i]=='e'||str[i]=='I'||str[i]=='i'||str[i]=='O'||str[i]=='o'||str[i]=='U'||str[i]=='u')
count++;
cout<<" number of vowel present in "<<str<<" = "<<count;
return 0;
}
Enter a string : playwithcoding
Number of vowel = 4
advertisment