Professional Documents
Culture Documents
Practice
Practice
#include <string>
using namespace std;
int main(){
// ##1
// ##2
// ##3
// string str;
// cout<<"Enter: ";
// cin>>str;
// cout<<str<<endl;
// cin>>str;
// cout<<str<<endl;
// cin>>str;
// cout<<str<<endl;
1
// ##4
// ##5
2
from index 2 from the original string with "LOL"
// cout<<str4<<endl;
// ##6
3
//##7
// string str_="today";
// string::iterator it;
// for(it = str_.begin(); it != str_.end(); it++)
// { // cout<<*it //dereferencing
// *it = *it - 32;
// }
// cout<<str_;
// string str__="today";
// string::reverse_iterator it;
// for(it = str__.rbegin(); it != str__.rend(); it++)
// {
// cout<<*it; //dereferencing
// }
//
// ###8
// string str;
// cout<<"Enter a string: ";
// getline(cin, str);
// int spaces = 0;
// int vowels = 0;
// int consonants = 0;
// int s = 0;
// for(int i = 0; i < str.length(); i++)
// {
// if (str[i] == ' ' && str[i+1] != ' ')
// {
// spaces += 1;
// }
// else if (str[i] == 'a' or (str[i] == 'e') or (str[i]
== 'i') or (str[i] == 'o') or (str[i] == 'u') or
// (str[i] == 'A') or (str[i] == 'E') or
(str[i] == 'I') or (str[i] == 'O') or (str[i] == 'U') )
// {
// vowels += 1;
// }
// else if (str[i] == ' ')
// s += 1;
4
// else
// {
// consonants += 1;
// }
// }
// cout<<vowels<<endl;
// cout<<consonants<<endl;
// cout<<spaces + 1<<endl;
// // ##
Palindrome ##
// string str;
// cout<<"Enter a string: ";
// getline(cin, str);
// string str2;
// for(int i = str.length() - 1; i >= 0; i--)
// str2 += str[i];
// if (str2 == str)
// {
// cout<<"Palindrome";
// }
// else
// {
// cout<<"Not a Palindrome";
// }
return 0;
}