#include <stdio.h>
int main()
{
char st[1000],alpha;
int i,flag;
scanf("%[^\n]",st);
for(alpha='a'; alpha <= 'z';alpha++)
{
flag=0;
for(i=0;st[i]!='\0';i++)
{
if(st[i]== alpha || st[i]== alpha-32)//in entire string if ‘a’ is present
{
flag=1;
break;
}
}
if(flag == 0) //in entire string ‘a’ is not present
break;
}
if(flag == 0)
printf("not pangram");
else
printf("pangram");
return 0;
}
Output:
why should we take ,
ReplyDeletest[i]==alpha-32;
can u plz explain this??
This comment has been removed by the author.
Deleteif the input is like this AbCDefGHiJklmnOPQRSTUVwxYZ
Deletethen also it is a pangram.
st[i] == 'a' will only check the presence of 'a'. to check the presence of 'A' we use st[i] == 'a'-32
ascii value of 'a' = 97 and 97-32 = 65 and 65 is ascii value of 'A'