C programming (not c++) This programs input is a series of words. All words cons
ID: 3871898 • Letter: C
Question
C programming (not c++)
This programs input is a series of words. All words consist of only lowercase letters(a-z), no uppercase letters or digits or punctuation or other special symbols. The program reads until end-of-file, and then prints out the lowercase letters that were not seen in the input. Enter your input: the quick brown fox jumps over the lazy old dog Missing letters: enter your input: roll tide missing letters: a b c f g h j k m n p q s u v w x y z hitns: use an array of 26 elements to store the number of times you've seen the characters a through z initialize that array to zeroes and the increment a given location when you see that letter recall that lowercase letters are ASCII 97 (a) through ASCII 122(z). If you subtract 97 from a given character, you get a value in the range of 0 to 25.
Explanation / Answer
#include<stdio.h>
#include<string.h>
main()
{
int i=0;
int b[26];
for(i=0;i<26;i++)
{
b[i]=0;
}
char a[100000];
scanf(" %[^ ]s",&a);
int k=strlen(a);
for(i=0;i<k;i++)
{
if(a[i]<=122 && a[i]>=97)
{
b[a[i]-97]++;
}
}
printf("MISSING LETTERS:");
for(i=0;i<26;i++)
{
if(b[i]==0)
{
printf("%c ",97+i);
}
}
}
output:
roll tide
MISSING LETTERS:a b c f g h j k m n p q s u v w x y z
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.