Help answer a problem

Write a C++ program that defines a function that prints every “x” character in the string.
a. For example, with a string “Hello World” and x = 4, the function should print “lo”
b. With a string “Hello World” and x = 5, the function should print “ol”
c. With a string “Hello World” and x = 1, the function should print “Hello World” d. With a string “Hello World” and x = 2, the function should print “el ol”
Show me what code you have already and I'll see if I can help
Create a function that takes as its arguments the string and the increment d.
void strikeOut( string text, int d )

Use a standard for-loop to cycle through the text[i], writing out that character and incrementing i by d each pass. The length of the string is given by text.size().

That's about it. It's a one-line function.
Last edited on
Topic archived. No new replies allowed.