0% found this document useful (0 votes)
41 views3 pages

Akhilesh AP 2.3

The document summarizes an experiment conducted by a student on string algorithms. It includes two problems - one to check if a sentence is a pangram, and another to count the number of words in a string in CamelCase format. The student provided the code solutions to both problems and the outputs. The learning outcomes were practicing string algorithms like pangram checking and CamelCase word counting.

Uploaded by

harshit143singh
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)
41 views3 pages

Akhilesh AP 2.3

The document summarizes an experiment conducted by a student on string algorithms. It includes two problems - one to check if a sentence is a pangram, and another to count the number of words in a string in CamelCase format. The student provided the code solutions to both problems and the outputs. The learning outcomes were practicing string algorithms like pangram checking and CamelCase word counting.

Uploaded by

harshit143singh
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/ 3

Experiment-2.

Student Name: Akhilesh Kumar Singh UID: 21BCS7126


Branch: BE-CSE Section/Group: 21BCS_IOT-605 B
Semester: 5th Date of Performance: 20/10/23
Subject Name: Advance Programming Lab Subject Code: 21CSP-314

 AIM:
String Algorithms: Demonstrate the concept of string

Problem 1
 Objective:
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.

 Code
def pangrams(s):
letter_set = set()
for char in s:
char = char.lower()
if char.isalpha():
letter_set.add(char)
if len(letter_set) == 26:
return "pangram"
return "not pangram"
user_input = input()
result = pangrams(user_input)
print(result)

Name: Akhilesh Kumar Singh UID: 21BCS7126


 Output

Problem 2
 Objective:
There is a sequence of words in CamelCase as a string of letters, s, 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 the rest of the
letters are lowercase.
Given s, determine the number of words in s.

 Code:
#include <bits/stdc++.h>
#include <string>

using namespace std;

int camelcase(const string& s) {


int word_count = 1;

Name: Akhilesh Kumar Singh UID: 21BCS7126


for (char c : s) {
if (isupper(c)) {
word_count++;
}
}
return word_count;
}

int main() {
string s;
cin >> s;
int result = camelcase(s);
cout << result << endl;
return 0;
}

 Output:

Learning Outcomes:
The learning outcomes from this coding exercise involving string algorithms include:
 Practiced different algorithms to work with strings like Pangram and CamelCase.
 Solved Problems related to these algorithms.

Name: Akhilesh Kumar Singh UID: 21BCS7126

You might also like