Modify Program 8.3, letters.cpp, so that a vector of 26 elements, indexed from 0 to 25, is used to track how many times each letter in the range ’a’–’z’ occurs. To do this, map the character ’a’ to 0,...


Modify Program 8.3, letters.cpp, so that a vector of 26 elements, indexed from 0 to 25, is used to track how many times each letter in the range ’a’–’z’ occurs. To do this, map the character ’a’ to 0, ’b’ to 1,…, and ’z’ to 25. Isolate this mapping in a function CharToIndex whose header is


int CharToIndex(char ch)


// pre: ’a’ <=>


// post: returns 0 for ’a’, 1 for ’b’, ... 25 for ’z’


Note that ’a’ - ’a’ == 0, ’b’ - ’a’ == 1, and ’z’ - ’a’ == 25.)



Nov 29, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here