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;
}
0 comments:
Post a Comment