Jump to content

Pangram checker: Difference between revisions

→‎{{header|C}}: drop unneeded headers; slight cleanup
(→‎{{header|TXR}}: Stray text removed.)
(→‎{{header|C}}: drop unneeded headers; slight cleanup)
Line 232:
=={{header|C}}==
<lang C>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int isPangram(const char *string)
{
char ch, wasused[26] = {0};
int total = 0;
 
while ((ch = *string++)) {
memset(wasused, 0, sizeof(wasused));
while (ch = *string++) {
int index;
 
Line 250 ⟶ 247:
else
continue;
 
if(!wasused[index]) {
total += !wasused[index] = 1;
if(!wasused[index]) {= 1;
total++;
}
}
return (total==26);
Line 260 ⟶ 256:
int main()
{
int i;
const char *pangram = "The quick brown fox jumps over the lazy dog.";
const char *not_a_pangramtests[] = "The qu1ck brown fox jumps over the lazy d0g.";{
const char *pangram = "The quick brown fox jumps over the lazy dog.";,
printf("\"%s\" is %sa pangram\n", pangram, isPangram(pangram)?"":"not ");
"The qu1ck brown fox jumps over the lazy d0g."
printf("\"%s\" is %sa pangram\n", not_a_pangram, isPangram(not_a_pangram)?"":"not ");
};
 
for (i = 0; i < 2; i++)
printf("\"%s\" is %sa pangram\n", pangram, isPangram(pangram)?"":"not ");
tests[i], isPangram(tests[i])?"":"not ");
return 0;
}</lang>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.