Skip to content

Instantly share code, notes, and snippets.

@mahababa
Created July 3, 2019 17:59
Show Gist options
  • Save mahababa/7d58bd9185cb6ae72a8bf52f6a258eed to your computer and use it in GitHub Desktop.
Save mahababa/7d58bd9185cb6ae72a8bf52f6a258eed to your computer and use it in GitHub Desktop.
Pangram Checking using C
#include<stdio.h>
void main()
{
int arr[26] = {0}; // Alphabet Array to count no of occurence
char str[] = "ABCDEFGHIJKLMNOPQRSTuvwxYZ"; //Input String
int i = 10, count = 0, l = 0;
//iterating every member of the input string
for(i= 0; str[i] != '\0' ; i++)
{
l = str[i]; // Getting the ascii values 'a' = 97 and 'A' = 65
if(l>=97 && l<=123) //Lower case Segregation
{
arr[l-97]+=1;
if(arr[l-97]==1) //Only check the variable for once, even if 'A' occurs say 'n' times, its first occurence counts
{
count++;
}
}
else if(l>=65 && l<=91) // Upper case segregation
{
arr[l-65]+=1;
if(arr[l-65]==1)
{
count++;
}
}
}
if(count==26) // if count == total no of alphabets ie 25 ubcluding 0
printf("yes");
else
printf("no");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment