Skip to content

Commit 4c6d443

Browse files
piyush-pawar-17t2013anurag
authored andcommitted
Added Pangram Checker in C++ (#736)
1 parent 6fcc570 commit 4c6d443

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

is_pangram/is_pangram.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <iostream>
2+
#include <vector>
3+
using namespace std;
4+
5+
bool is_pangram(string str) {
6+
7+
vector<bool> pangram(26, false);
8+
9+
for (int i = 0; i < str.length(); i++) {
10+
if (str[i] >= 'A' && str[i] <= 'Z')
11+
pangram[str[i] - 'A'] = true;
12+
if (str[i] >= 'a' && str[i] <= 'z')
13+
pangram[str[i] - 'a'] = true;
14+
}
15+
16+
for (int i = 0; i < 26; i++)
17+
if (!pangram[i])
18+
return false;
19+
20+
return true;
21+
}
22+
23+
int main() {
24+
25+
bool pangram = is_pangram("The quick brown fox jumps over the lazy dog");
26+
if (pangram)
27+
cout << "Given string is a pangram" << endl;
28+
else
29+
cout << "Given string is not a pangram" << endl;
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)