CIS 2500 Chapter 1.6: CIS 2500 Chapter 1.: Chapter 1.6 Arrays

43 views1 pages

Document Summary

Program counts the number of occurrences of each digit, of whitespace characters and other characters. int ndigit[10]; declares an array of 10 integers. Array subscripts always start at 0. if (c >= "0" && c <= "9") checks to see if the character in c is a digit. The numeric value of the digit is c - "0" Chars are small integers, meaning char variables and constants are identical to ints in arithmetic expressions. Ie. c-"0" is an integer expression with a value between 0 and 9 corresponding to the character "0" to "9" stored in c. The if else statements decide wehterh a character is a digit, whitespace or something else. Multiple if statements are used as a multi-way decision, and the conditions are evaluated from top to bottom until a condition is satisfied. If none of the conditions are satisfied, the else is executed. Switch statements are also used to express multi-way decisions.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents