1. Engineering
  2. Computer Science
  3. 51 specification write an ansic program that takes input from...

Question: 51 specification write an ansic program that takes input from...

Question details

5.1 Specification Write an ANSI-C program that takes input from Standard in, and outputs the occurrence count of digits 0-9 in the inputs 5.2 Implementation name your program lab2D.c use getchar and putchar to read from the standard input. The program continues to read until EOF is entered. Then outputs the occurrence count of each digit in the input. use an integer array as the counters, dont use 10 individual counters. . when a character is read in, how to find the corresponding counter? Dont use statement such as if (c-. 0 ) else if (c--1) else if (c-# 2 ) else Instead, use the one-statement trick discussed in class, which takes advantage of the index of the character to figure out the corresponding counter in the array. 5.3 Sample Inputs/Outputs: (download the input file input.txt) red 368 % gcc -Wall lab2D.c -。1ab2d red 369 % lab2d YorkU LAS C D (press Ctrl and D)

0: 0 2: 0 4: 0 5: 0 6: 0 9: 0 red 370 lab2d EECS20312 CB121 D (press Ctrl and D) 2: 2 4: 0 5: 0 6: 0 9: 0 red 371 % 1ab2d EECS3421 thiw is good 3 address 500 yu266074 423Dk D (press ctrl and D)

423Dk D (press Ctrl and D) 0: 3 2: 3 3: 3 4: 3 6: 2 8: 0 9: 0 red 372 % lab2d < input.txt 0: 4 1: 7 2: 4 3: 4 4: 5 5: 2 6: 2 7: 5 8: 0 9: 0 red 373 %

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution