Professional Documents
Culture Documents
Experiment 2.3
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);
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);
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.