Given an input line, capitalize first and last letter of each word in the given line. It\'s provided that the input line is in lowercase
belongs to collection: Interview C++ coding problems/challenges | Coding Algorithms
All Answers
total answers (1)
The basic algorithm is to keep track of the spaces and to capitalize the letter before space & after space. Also, the first letter and the last letter of the line should be capitalized.
Few more things that need to be kept in mind such that:
Algorithm:
line [index]-=32;
Inclusion of hash table in the program helps us to avoid inserting duplicate indexes. Otherwise, corner test-cases may fail.
C++ program to capitalize first and last letter of each word in a line
Output
need an explanation for this answer? contact us directly to get an explanation for this answer