SHARE
TWEET

Untitled

a guest Jan 21st, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #define WORDS 10
  5. #define COL 50
  6. #define ASCII_A 97
  7. #define ASCII_Z 122
  8. #define NUM_LETTERS 26
  9. //This code is taking the words that the user entered and checks if the sentence is pangram.
  10. int main(void)
  11. {
  12.     int notYet = 1; // It's showing if it's already a pangram.
  13.     int englet = 0;
  14.     int engLetter = 0;
  15.     int word = 0;
  16.     int letter = 0;
  17.     int i = 0;
  18.     int j = 0;
  19.     char englishLetters[NUM_LETTERS] = {0};
  20.     char pangram[WORDS][COL] = {0};
  21.     printf("Enter up to 10 words, try to make a pangram:\n");
  22.     for(i = 0; (i < WORDS) && (notYet > 0); i++)
  23.     {
  24.         for(j = 0; j < NUM_LETTERS; j++)
  25.         {  
  26.             englishLetters[j] = 1;
  27.         }
  28.         fgets(pangram[i], WORDS, stdin);
  29.         if(strlen(pangram[i]) < COL)
  30.         {
  31.             pangram[i][strlen(pangram[i])-1] = 0;
  32.         }
  33.         for(englet = ASCII_A; englet <= ASCII_Z; englet++)
  34.         {
  35.             for(word = 0; word < WORDS; word++)
  36.             {
  37.                 for(letter = 0; letter < strlen(pangram[word]); letter++)
  38.                 {
  39.                     if((pangram[word][letter] == englet) && (englishLetters[engLetter] != 0))
  40.                     {
  41.                         englishLetters[engLetter] = 0;
  42.                     }
  43.                 }
  44.             }
  45.         }
  46.         notYet = 0;
  47.         for(englet = 0; (englet > NUM_LETTERS) && (notYet == 0); englet++)
  48.         {
  49.             if(englishLetters[englet] != 0)
  50.             {
  51.                 notYet++;
  52.                 printf("\n");
  53.             }
  54.         }
  55.         engLetter++;
  56.     }
  57.     if(notYet == 0)
  58.     {
  59.         printf("It's a pangram?\nYes!");
  60.     }
  61.     else
  62.     {
  63.         printf("It's a pangram?\nNo");
  64.     }
  65.     return(0);
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top