0% found this document useful (0 votes)
2 views5 pages

2.3AP

The document outlines Experiment 2.3 for a student named N Srinivas Rao, focusing on string manipulation in an Advanced Programming lab. It includes objectives to determine if a string is a pangram and to count words in a CamelCase string, along with corresponding C++ code implementations. Additionally, it lists learning outcomes related to tree data structures and graph traversal techniques.

Uploaded by

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

2.3AP

The document outlines Experiment 2.3 for a student named N Srinivas Rao, focusing on string manipulation in an Advanced Programming lab. It includes objectives to determine if a string is a pangram and to count words in a CamelCase string, along with corresponding C++ code implementations. Additionally, it lists learning outcomes related to tree data structures and graph traversal techniques.

Uploaded by

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

Experiment 2.

3
Student Name: N Srinivas Rao UID: 21BCS3949
Branch: CSE Section/Group: 902/B
Semester: 5th Date of Performance:22/10/2023
Subject Name: Advance Programming lab Subject Code: 21CSP-314

a.
Aim: Demonstrate the concept of string.

b.
Objective:

1. A pangram is a string that contains every letter of the alphabet. Given a


sentence determine whether it is a pangram in the English alphabet.
Ignore case. Return either pangram or not pangram as appropriate.
2. There is a sequence of words in CamelCase as a string of letters, ,
having the following properties:
• It is a concatenation of one or more words consisting of English
letters.
• All letters in the first word are lowercase.
• For each of the subsequent words, the first letter is uppercase
and rest of the letters are lowercase.
Given s, determine the number of words in s.

c.
Code:

a)
#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;

string pangrams(string s) {
unordered_set<char> letters;

for (char c : s) {
if (isalpha(c)) {
letters.insert(tolower(c));
}
}

return letters.size() == 26 ? "pangram" : "not pangram";


}

int main() {
string s;
getline(cin, s);

string result = pangrams(s);


cout << result << endl;

return 0;
}

b)
#include <iostream>
#include <string>

using namespace std;

int camelcase(string s) {
int wordCount = 1;
for (char c : s) {
if (isupper(c)) {
wordCount++;
}
}

return wordCount;
}

int main() {
string s;
cin >> s;

int result = camelcase(s);


cout << result << endl;

return 0;
}
Output:
(i)

(ii)
4. Learning Outcomes:

a. Learnt about non linear data structure that is tree.


b. Learnt about graph traversal techniques like preorder, postorder and inorder.
c. Learnt the differences between trees and graphs.

You might also like