How to Capitalize Every Vowel in a String in C++

This is a well logic build program in C++ about strings for beginners. The program will capitalize vowel in a given string like "Ali is a good boy" will become "AlI Is A gOOd bOy".


Source Code   


#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int main()
{
cout<<"\a\n\n\n"
<<"\t******************************************************"<<endl
<<"\t** **"<<endl
<<"\t** Welcome To **"<<endl
<<"\t** **"<<endl
<<"\t** Capitalize Vowel **"<<endl
<<"\t** **"<<endl
<<"\t** Demo **"<<endl
<<"\t** **"<<endl
<<"\t******************************************************"<<endl
<<endl
<<endl;
cout<<"";
string string1;
cout<<"Enter a string:\n";
getline(cin,string1);

for(int i=0; i<string1.length(); i++)
{
if(isalpha( string1.at(i) ) )
{
char vowel = string1.at(i);
switch (vowel) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
string1[i] = toupper( string1.at(i) );
break;
}
}
}

cout<<string1<<endl;
cout <<endl;
system("pause");
return 0;
}

Output of the Program 

Capitalize Every Vowel in a String in C++

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment