You are on page 1of 5

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment 2.3

Student Name: Aditya Singh UID: 21BCS2466


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

1. Aim: Demonstrate the concept of string.

2. Objective: a) 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.

b) 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 rest of the letters are lowercase.

Given s, determine the number of words in s.

3. DBMS script and output:


DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

a)
#include <bits/stdc++.h>
using namespace std;

string pangrams(string s) {
set<char> a;
for (auto& x : s) {
x = tolower(x);
}
for(int i=0;i<s.size();i++){
if(isalpha(s[i])){
a.insert(s[i]);
}
if(a.size()==26) return "pangram";
}
return "not pangram";
}

int main()
{
ofstream fout(getenv("OUTPUT_PATH"));

string s;
getline(cin, s);

string result = pangrams(s);

fout << result << "\n";


DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

fout.close();

return 0;
}

Result:

b) #include <bits/stdc++.h>
using namespace std;

int camelcase(string s) {
int r = 1;
for(int i = 0; i < s.size(); i++) {
if(s[i] < 'a') r++;
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

return r;
}

int main()
{
ofstream fout(getenv("OUTPUT_PATH"));

string s;
getline(cin, s);

int result = camelcase(s);

fout << result << "\n";

fout.close();

return 0;
}

Result:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Learning Outcome
• Learned about strings
• "string" is a data type used to represent a sequence of
characters.
• A character can be a letter, number, symbol, or even a space.
• You can perform various operations on strings, such as
concatenation (combining two or more strings), substring
extraction (getting a portion of the string), finding the length,
and searching for specific characters or substrings within the
string.

You might also like