Checking for pangrams in C This will test if a user entered an pangram (every letter in alphabet used at least once), however with 4 for loops there's got to be a better algorithmic approach or with the language of C itself.

pangram.c

 #include &lt;stdlib.h&gt;
 #include &lt;stdio.h&gt;
 #include &lt;string.h&gt;
 #include &lt;ctype.h&gt;

 typedef enum { true, false } bool;

 typedef struct node{
     char letter;
     bool exists;
 } node;

 int main(int argc, char *argv[]){
     int SIZE = 500;
     char input[SIZE];

     printf("Enter your pangram: ");
     fgets(input, SIZE, stdin);

     // 26 letters
     node alphabet[26];
     int i = 0;
     for(char c='a'; c&lt;='z'; ++c, i++){
         alphabet[i].letter = c;
         alphabet[i].exists = false;
     }


     for(int i=0; i&lt;SIZE; i++){
         for(int j=0; j&lt;27; j++){
             if(isalpha(input[i]) &amp;&amp; input[i] == alphabet[j].letter){
                 alphabet[j].exists = true;
             }
         }
     }

     for(int i=0; i&lt;27; i++){
         if(alphabet[i].exists==false){
             printf(" no pangram, missing letter.\n");
             return 1;
         }
     }

     printf("you've entered a pangram.\n");

     return 0;
 }


command line:

&gt;&gt; gcc -o pangram pangram.c -std=c99; ./pangram
Enter your pangram: this should fail
 no pangram, missing letter.

&gt;&gt; gcc -o pangram pangram.c -std=c99; ./pangram
Enter your pangram: the quick brown fox jumps over the lazy dog
you've entered a pangram.
Please never define true to have the value 0, since that value is reserved for the name false. Just include &lt;stdbool.h&gt; instead of defining the type yourself.

Do not call any function from &lt;ctype.h&gt; with a char argument since that can easily lead to undefined behavior.

In the call to fgets fails, the input array may be uninitialized, which would also lead to undefined behavior.

Accessing alphabet[26] leads to undefined behavior since there valid array indices go from 0..25.

The rest of your code looks well-organized and is easy to read. Congratulations on that.

For your primary question of solving the pangram with fewer than 4 for loops, you can find at least 10 different solutions by searching the web since the pangram is a classical programming task.

Forget the above paragraph. I just searched for "pangram c" and found only crappy solutions, and telling these apart from the good ones is impossible for a beginner.

One idea is to remember for each letter whether it was found it not:

bool found[26] = { false };   // This initializes all 26 values at once, but only works for "zero" values.
int remaining = 26;

for (size_t i = 0; input[i] != '\0'; i++) {
    char ch = input[i];

    if ('a' &lt;= ch &amp;&amp; ch &lt;= 'z') {
        if (!found[ch - 'a']) {
            found[ch - 'a'] = true;
            remaining--;
        }
    }
}


If, at the end of the loop, there is no remaining character, you have found them all, and the input is a pangram. All with a single loop.

Note: the code I suggested only works when all 26 letters are defined in a contiguous block of the character set. On all modern systems this is the case. When working with IBM machines and EBCDIC encoding, this will not work. On Rosetta Code, the code is perfect and also handles these exotic cases. It uses the same idea and takes care of everything. It looked complicated at first sight, therefore I preferred to explain the basic idea first. But now you should be able to understand the code over there.