HackerRank: Pangrams C Program to check If a string contains every letter of alphabet

A pangram is a string that contains every letter of the alphabet. Given a sentence determine whether it is a pangram in the English alphabet. Ignore case. Return either pangram or not pangram as appropriate.


The string contains all letters in the English alphabet, so return pangram.

Function Description

Complete the function pangrams in the editor below. It should return the string pangram if the input string is a pangram. Otherwise, it should return not pangram.

pangrams has the following parameter(s):

string s: a string to test

string: either pangram or not pangram

char* pangrams(char* s) {
    int *arr = calloc(26, sizeof(int));
    int index;
    char *str1 = malloc(sizeof(40));
    char *str2 = malloc(sizeof(40));
    str1 = "pangram";
    str2 = "not pangram";
    for(int i=0; i<strlen(s); i++){
        if(s[i]>='A' && s[i]<='Z'){
            index = s[i] - 'A';
        else if(s[i]>='a' && s[i]<='z'){
            index = s[i] - 'a';
        arr[index] = 1;
    int flag = 1;
    for(int i=0; i<26 ;i++){
            flag = 0;
        return str1;
return str2;

Leave a Comment