The following is the skeleton of a C program that computes the number of each nu
ID: 3639700 • Letter: T
Question
The following is the skeleton of a C program that computes the number of each numeral in a string. Fill inthe blanks with appropriate C constructs. (10)
#include <stdio.h>
#define base 10
main () /* This program outputs the numbers of 0's,1's, : : :, 9's in an
input string ending in $ */
f
char b;
int i, a[base];
/* Initialize array elements to zero */
for ( ; ; )
a[i] = 0;
printf("Input numeric characters ending with $ " );
scanf("%c", &b); /* Scan next character */
/* Execute the loop as long as $ is not scanned */
while ( ) f
printf("Processing the digit %c ", b);
/* Increment the count for the new digit */
a[
scanf("%c", &b); /* Scan next character */
g
for ( i=0 ; i<=9 ; i=i+1 )
printf("There are % % 's ", a[i], i);
Explanation / Answer
#include #define base 10 main () /* This program outputs the numbers of 0's,1's, : : :, 9's in an input string ending in $ */ f char b; int i, a[base]; /* Initialize array elements to zero */ for ( i = 0 ; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.