Ritik Kumar EXP 5 Merged AP LAB (Nemesis)
Ritik Kumar EXP 5 Merged AP LAB (Nemesis)
Experiment 5(A)
Student Name: Ankush Kumar UID: 22BCS10661
Branch: CSE Section/Group: 608/A
Semester: 5 Date of Performance: 21/08/24
Subject Name: Advanced Programming Lab-1 Subject Code: 22CSP-314
1. Title: Pangrams
2. Aim: Pangram is a string that contains every letter of the alphabet. Givena sentence
determinewhether it is a pangram in the English alphabet. Ignorecase. Returneither
pangram or not program as appropriate
3. Objective:
Complete the function pangrams in the editor below. It should return the string
pangram if the input string is a pangram. Otherwise, it should return not
pangram.pangramshasthefollowingparameter(s):
string s: astring to test
It returns either pangram or not pangram
4. Algorithm:
• Update the array at the index corresponding to the lowercase letter of each character.
• Return "pangram"
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
5. Implementation/Code
#include <bits/stdc++.h>
using namespace std;
string pangrams(string s) {
bool letters[26] = {false};
for (char c : s) {
if (isalpha(c)) {
letters[tolower(c) - 'a'] =
true;
}
}
for (bool present : letters) {
if (!present) {
return "not pangram";
}
}
return "pangram";
}
int main() {
string s;
getline(cin, s);
cout << pangrams(s) <<
endl;
return 0;
}
6. Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
7. Learning Outcomes:
→ Understand how to use boolean arrays to track the presence of
characters.
→ Learn to efficiently check for the presence of all letters in a string.
→Implement basic string and array operations for character counting and
validation.
8. Time Complexity: O(nl)
Experiment 5(B)
Student Name: Ritik Kumar UID: 22BCS10767
Branch: CSE Section/Group: 608/B
Semester: 5 Date of Performance: 21/08/24
Subject Name: Advanced Programming Lab-1 Subject Code: 22CSP-314
1. Title: Pangrams
4. Algorithm:
Experiment 5(C)
Student Name: Ritik Kumar UID: 22BCS10767
Branch: CSE Section/Group: 608/B
Semester: 5 Date of Performance: 21/08/24
Subject Name: Advanced Programming Lab-1 Subject Code: 22CSP-314
2. Aim:
Louise joined a social networking site to stay in touch with her friends. The signup
pagerequiredher to inputa nameanda password. However, thepasswordmust be
strong. Thewebsiteconsidersa password be strong if it satisfies thefollowingcriteria:
Its length is at least 6.
It contains at least one digit.
It contains at leastonelowercase Englishcharacter.
It contains at leastoneuppercase Englishcharacter.
It contains at leastonespecialcharacter. The special characters are: !@#$%^&*()-+
3. Objective:
Iterate through each character in the password and set the appropriate flags.
Return the maximum of the needed characters or the difference to reach length 6.
5. Implementation/Code
#include <bits/stdc++.h>
using namespace std;
int minimumNumber(int n,
const string& password) {
bool hasUpper = false;
bool hasLower = false;
bool hasDigit = false;
bool hasSpecial = false;
Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
6. Learning Outcomes:
→Learn how to check for the presence of different char types in a password.
→Understand how to determine the number of characters needed to meet
password strength criteria.
→Implement logic for handling edge cases related to password length and
character requirements.