Lab Task 8 Pf Sherry
Lab Task 8 Pf Sherry
Languages
Name:
Nimra Azeem
Class:
BSCS
NUML Id:
NUML-F24-39415
Semester:
1st
Subject:
Programming Fundamentals
Submitted To:
Sir Shahroz Tariq
LAB TAK NO 8
Write a program in C++ that will ask user to input your name in lowercase and perform
following functions on it and display relevant output:
✓ Print Name in UPPERCASE
✓ Print Name in Reverse
✓ Count Vowel
CODE:
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
int counta=0,counte=0,counti=0,counto=0,countu=0;
string textin;
cout<<"Enter Your Name: ";
getline(cin, textin);
transform(textin.begin(), textin.end(), textin.begin(), ::toupper);
cout<<"Reversed Uppercase Name is: "<<textin<<endl;
reverse(textin.begin(), textin.end());
transform(textin.begin(), textin.end(), textin.begin(), ::toupper);
cout<<"Reversed Uppercase Name is: "<<textin<<endl;
//Now counting No of Vowels:
for(int i=0;i<textin.length();i++)
{
if(textin[i]=='a'||textin[i]=='A')
{
counta++;
}
if(textin[i]=='e'||textin[i]=='E')
{
counte++;
}
if(textin[i]=='i'||textin[i]=='I')
{
counti++;
}
if(textin[i]=='o'||textin[i]=='O')
{
counto++;
}
if(textin[i]=='u'||textin[i]=='U')
{
countu++;
}
}
cout<<"Number of Vowels :"<<endl;
cout<<"A = "<<counta<<endl;
cout<<"E = "<<counte<<endl;
cout<<"I = "<<counti<<endl;
cout<<"O = "<<counto<<endl;
cout<<"U = "<<countu<<endl;
}