C Program
#include <stdio.h> #include <ctype.h> #include <string.h> int isPangram(char str[]) { int seen[26] = {0}; for (int i = 0; str[i] != '\0'; i++) { if (isalpha(str[i])) { char c = tolower(str[i]); seen[c - 'a'] = 1; } } for (int i = 0; i < 26; i++) { if (seen[i] == 0) return 0; } return 1; } int main() { char str[200]; printf("Enter a sentence: "); fgets(str, sizeof(str), stdin); if (isPangram(str)) printf("The sentence is a Pangram.\n"); else printf("The sentence is NOT a Pangram.\n"); return 0; }
C Output
Input:
The quick brown fox jumps over the lazy dog
Output:
The sentence is a Pangram.
C++ Program
#include <iostream> #include <cctype> #include <string> using namespace std; bool isPangram(string str) { bool seen[26] = {false}; for (char c : str) { if (isalpha(c)) { seen[tolower(c) - 'a'] = true; } } for (int i = 0; i < 26; i++) { if (!seen[i]) return false; } return true; } int main() { string str; cout << "Enter a sentence: "; getline(cin, str); if (isPangram(str)) cout << "The sentence is a Pangram." << endl; else cout << "The sentence is NOT a Pangram." << endl; return 0; }
C++ Output
Input:
Hello world
Output:
The sentence is NOT a Pangram.
JAVA Program
import java.util.Scanner; public class PangramCheck { static boolean isPangram(String str) { boolean seen[] = new boolean[26]; for (char c : str.toCharArray()) { if (Character.isLetter(c)) { seen[Character.toLowerCase(c) - 'a'] = true; } } for (boolean b : seen) { if (!b) return false; } return true; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter a sentence: "); String str = sc.nextLine(); if (isPangram(str)) System.out.println("The sentence is a Pangram."); else System.out.println("The sentence is NOT a Pangram."); sc.close(); } }
JAVA Output
Input:
Pack my box with five dozen liquor jugs
Output:
The sentence is a Pangram.
Python Program
def is_pangram(s): seen = set() for ch in s.lower(): if ch.isalpha(): seen.add(ch) return len(seen) == 26 sentence = input("Enter a sentence: ") if is_pangram(sentence): print("The sentence is a Pangram.") else: print("The sentence is NOT a Pangram.")
Python Output
Input:
Sphinx of black quartz, judge my vow
Output:
The sentence is a Pangram.
In-Depth Explanation
Example
A pangram is a sentence that uses all the letters of the alphabet at least once. Some famous examples are "The quick brown fox jumps over the lazy dog" and "Pack my box with five dozen liquor jugs." On executing the program, it iterates over all the characters of the input sentence, flags the letters that we have encountered, and finally checks whether all the 26 English letters were accounted for. If yes, then the given sentence is a pangram; otherwise not.
Real-Life Analogy
Picture yourself building a set of 26 different stickers, each of them corresponding to a letter from A to Z. If when you finish your set you have all 26, your set is complete. A pangram is much the same collection—it ensures that all letters are included at least once in the sentence. Having missing any single sticker means your set is incomplete, much like the case of a non-pangram sentence.
Why It Matters
The idea of pangrams is highly sought after in typography and keyboard testing. Designers utilize pangram sentences to print out all alphabets in a specific font so that no letter appears strange or out of place. While coding, it provides us with experience in dealing with strings, character sets, and boolean arrays or sets to manage information in an efficient way.
Learning Insights
This exercise educates newcomers to work with strings, manipulate case insensitivity, and monitor if certain conditions have been satisfied with arrays or sets. It also introduces character-to-index mapping (c - 'a' in C/C++/Java), which is an important technique for most algorithmic problems such as anagramming, frequency analysis, and cryptography.
Programming Applications
Pangram testing can be generalized into practical usages such as spell checkers, language learning software, or even casual puzzle games. During interviews, such questions not only put your understanding of loops and conditionals to the test but also how you approach mapping problems to optimal data structures such as arrays, hash maps, or sets.
SEO-Optimized Closing Paragraph
Pangram checking in computer programming allows students to enhance their string manipulation abilities while discovering how to efficiently monitor characters and conditions. This easy-to-understand program demonstrates how to check for the validity of whether or not a sentence has all 26 letters of the English alphabet, something that is a popular question for coding interviews and competitive programming contests. By solving pangram programs in C, C++, Java, and Python, beginners will build confidence in handling strings, problem-solving, and algorithm design and hence is an ideal exercise for exam, interview, or real-world project preparation.
Social Plugin