0% found this document useful (0 votes)
4 views4 pages

Lab Task 8 Pf Sherry

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Lab Task 8 Pf Sherry

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

National University of Modern

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;
}

You might also like