Control flow

4.5 - Range based for loop


There's another kind of for loop called the range based for loop. This for loop iterates over every element in a range. For example it can be used to iterate over every character in a string.

An example of a range based for loop to iterate over every character in a string:

for (char c : "chicken") {
    std::cout << c << std::endl;
}

Task

Your task is to create a code which receive a word and then prints out each letter of the word on a different line.

Sample input

chicken

Sample output

c
h
i
c
k
e
n
#include <iostream> int main() { // Start your program here }