C++ Program to find vowel and its position in a string.
/*
Author: Shubham Patil
copyright
*/
#include <iostream>
using namespace std;
int main()
{
char str[10];
cout<<"\tEnter a word to find vowels and position\n";
cin>>str;
cout<<str;
int n = sizeof(str)/sizeof(str[0]);
cout<<"Vowels in string "<<str<<":\n";
for(int i=0;i<n;i++)
{
if(str[i]=='a'||str[i]=='A')
{
cout<<"'a' position: "<<i<<"\n";
}
else if(str[i]=='e'||str[i]=='E')
{
cout<<"'e' position: "<<i<<"\n";
}
else if(str[i]=='i'||str[i]=='I')
{
cout<<"'i' position: "<<i<<"\n";
}
else if(str[i]=='o'||str[i]=='O')
{
cout<<"'o' position: "<<i<<"\n";
}
else if(str[i]=='u'||str[i]=='U')
{
cout<<"'u' position: "<<i<<"\n";
}
}
return 0;
}
iamaniceperson
iamanicepersonVowels in string iamanicepe
:
'i' position: 0
'a' position: 1
'a' position: 3
'i' position: 5
'e' position: 7
'e' position: 9
0 Comments