Linux Example – Terminal
Another assignment that I made for my C programming class at TCC. Pangram program, this program check if your sentence is a pangram or not. Pangram is a sentence using every letter of the alphabet at least once. I compile using Dev-C++ for windows and for Linux , Mac or any Unix console CC. If you running this program maybe your anti-virus can told you that maybe is a risk to running this program. Is because is very basic, but is NOT A VIRUS.
Windows Example – Command Prompt
In this program you can see a good example for for loop in c programing . Also is a good example for see how to stored a array of character using char. This code and program is free to use and share, any questions free to ask.
Download Source Code
Pangram- Windows (.exe)
Pangram- Linux (.out)
//XD Creations - www.xd100.wordpress.com /*Pangram program, this program check if your sentence is a pangram or not Pangram is a sentence using every letter of the alphabet at least once. Exmaple : The quick brown fox jumps over a lazy dog*/ #include <stdio.h> int main(void) { int index, i, pangram; char ch, x[26] = {0}; printf("\n\n------------------------------------------\n"); printf("Enter a sentence to check if is a pangram\n"); printf("------------------------------------------\n"); printf("----------- Pangram Program --------------\n"); printf("Enter a pangram: "); /* This While Loop checking if is a pangram or not. The program increment 1 for each that letter you enter. So, if you have at least one and each letter is a pangram*/ while ((ch = getchar()) != '\n'){ // This time I dont used scanf, I used getchar if('A'<=ch&&ch<='Z')// checking if Cap letter index = ch-'A'; else if('a'<=ch&&ch<='z') // checking if isn't Cap letter index = ch-'a'; else continue; x[index] = 1;// Here is stored all the letter with numbers. } pangram = 1; // Basically this is loop that check if you have all letters. for (i = 0; i < 26; ++i) { if (x[i] == 0) pangram = 0; } // If you have all letter, the array increment 1 and is a pangram if (pangram == 1){ printf("------------------------------------------\n"); printf("Your sentence have all letter so is, Pangram\n"); printf("------------------------------------------\n"); printf(" By: XD Creations"); } // If you dont have all letter, the array dont increment and isn't a pangram else if(pangram == 0) { printf("------------------------------------------\n"); printf("This sentence is not a Pangram\n"); printf("------------------------------------------\n"); printf(" By: XD Creations\n"); } printf("\n\n"); system("PAUSE");// system("PAUSE"); is just for windows return 0; } //XD Creations - www.xd100.wordpress.com