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