📝📚Intermediate

Check For Pangram String

Check if contains all alphabets

A pangram is a sentence containing every letter of the alphabet at least once.

Program Code

pangram.c
C
1#include <stdio.h>
2#include <string.h>
3#include <ctype.h>
4#include <stdbool.h>
5
6bool isPangram(char str[]) {
7 bool alphabet[26] = {false};
8
9 for (int i = 0; str[i]; i++) {
10 if (isalpha(str[i])) {
11 alphabet[tolower(str[i]) - 'a'] = true;
12 }
13 }
14
15 // Check if all letters present
16 for (int i = 0; i < 26; i++) {
17 if (!alphabet[i]) {
18 return false;
19 }
20 }
21 return true;
22}
23
24int main() {
25 char str1[] = "The quick brown fox jumps over the lazy dog";
26 char str2[] = "Hello World";
27
28 printf("\"%s\"\n", str1);
29 printf("Is pangram: %s\n\n", isPangram(str1) ? "Yes" : "No");
30
31 printf("\"%s\"\n", str2);
32 printf("Is pangram: %s\n", isPangram(str2) ? "Yes" : "No");
33
34 return 0;
35}
Output

"The quick brown fox jumps over the lazy dog"

Is pangram: Yes

 

"Hello World"

Is pangram: No