Write a complete program using two arrays, upper and lower to keep the upper And
ID: 3538950 • Letter: W
Question
Write a complete program using two arrays, upper and lower to keep the upper
And lower alphabet respectively.
Ask the user to enter string example:
This is a test from Jupiter. Soon you will see who is from Jupiter!!! May be Dr. D.
Your program should parse the string and keep track of number of alphabet. Both arrays are indexed from 0 to 25. The logical way to do this is to use upper[0] to
Count the number of %u2018A%u2019, and upper[1] to count number of %u2018B%u2019 and so on. Likewise
For the lower array.
Output should look like:
A: 0 a:2
B: 0 b:0
when you finish, please send to this email:bgmds@126.com and post your email below, i will rate 5 stars for fastest or best one. please write the code yourself, no copy. thx
Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
int main()
{
int upper[26],lower[26];
int i;
for(i=0;i<26;i++)
upper[i]=lower[i]=0;
char c;
printf("Enter a string: ");
while((c=getchar())!=' ')
{
if(c>='a' && c<='z')
{ lower[c-'a']++; }
else if(c>='A' && c<='Z')
{ upper[c-'A']++; }
}
printf(" Characters Counted ");
for(i=0;i<26;i++)
printf("%c: %d %c: %d ",i+'A',upper[i],i+'a',lower[i]);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.