Professional Documents
Culture Documents
Bse 231023 Mudssar Aslam
Bse 231023 Mudssar Aslam
#include <iostream>
#include<string>
int main()
string str;
getline(cin,str);
int w_count=0;
for(int i=str.length()-1;i>=0;i--)
if(str[i]==' ')
w_count++;
str.append("hellow world");
cout<<endl;
str[i] += 32;
Task 2
#include <iostream>
#include <string>
int main() {
string str;
cout << "The total number of vowels is " << a_count + e_count + i_count + o_count + u_count
<< endl;
return 0;
}
Task 3
#include <iostream>
#include <string>
int main() {
string Phone_No;
do {
cout << "Enter a number: ";
getline(cin, Phone_No);
if (Phone_No.length() != 12) {
cout << "Invalid input. The input string must be of size 12." << endl;
continue;
}
switch (city_code) {
case 51:
cout << "This number belongs to Islamabad." << endl;
break;
case 42:
cout << "This number belongs to Lahore." << endl;
break;
case 21:
cout << "This number belongs to Karachi." << endl;
break;
default:
cout << "Un-known number." << endl;
break;
}
cout << "Do you want to enter another number (y/n): ";
char ch;
cin >> ch;
}
while ( ch == 'y' || ch=='Y');
Task 4
#include <iostream>
#include<string>
using namespace std;
int main() {
string str, str_new, str_old;
return 0;
}