top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Write a program to identify a sentace is a Pangram or not.

+5 votes
2,438 views

Take a string as an input and identify whether it is Pangram or not. Pangrams are those sentences,which is constructed by using all letters of the alphabet at least once.

posted Mar 22, 2016 by Shahsikant Dwivedi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
 
Best answer

Pangrams are words or sentences containing every letter of the alphabet at least once; the best known English example being A quick brown fox jumps over the 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: <span class="wp-smiley wp-emoji wp-emoji-lol" title="XD">XD</span> 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: <span class="wp-smiley wp-emoji wp-emoji-lol" title="XD">XD</span> Creations\n");
    }
 printf("\n\n");
    system("PAUSE");// system("PAUSE"); is just for windows
    return 0;
}
answer Mar 22, 2016 by Manikandan J
printf(" By: <span class="wp-smiley wp-emoji wp-emoji-lol" title="XD">XD</span> Creations\n");
    }
what's this?
i think that line is code for emoji ,it will print emoji when we run this code in any C IDE.
giving an error not printing any emo ,initially i figured it out as you are saying,but it's not true
Similar Questions
+6 votes

Take input 'n' as number of strings and find the common alphabet among them.
For example:
Input:

Number of Strings - 3
List of Strings - 
abcdde
baccd
eeabg

output:

2   

as 'a' and 'b' are only two common alphabet among those three strings

–1 vote

Write a C program to check if the given string is repeated substring or not.
ex
1: abcabcabc - yes (as abc is repeated.)
2: abcdabababababab - no

+2 votes

Write a C program which accept two strings and print characters in second string which are not present in first string?

Example:
String 1: apple
String 2: aeroplane

output:
ron

0 votes

Enter character: r
Enter string: programming
Output: Positions of 'r' in programming are: 2 5
Character 'r' occurred for 2 times

...