Computer Science, asked by kkanokia, 1 year ago

Write a program in c++ to accept a string and print the total no of vowels in it also print the string in upper and lower case

Answers

Answered by vbhvsolanki7500
8

#include<bits/stdc++.h>

using namespace std;

int main()

{

   string s,lower,upper;

   s = "Hello World";

   string vowel = "aeiou";

   int r = vowel.length();

   int l = s.length();

   int c=0;//to count the no. of vowels

   for(int i=0;i<l;i++)

   {

       if(vowel.find(s[i])<r)

       {

           c++;

       }

       char x;

       x = s[i];

       x = tolower(s[i]);

       lower+=x;

       x = toupper(s[i]);

       upper+=x;

   }

   cout<<"Total Vowels: "<<c<<endl;

   cout<<"Lowercase: "<<lower<<endl;

   cout<<"Uppercase: "<<upper;

}


Similar questions