From the course: C Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Repeat some text

Challenge: Repeat some text - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Challenge: Repeat some text

(upbeat music) - [Instructor] For this challenge, use exercise file 03_09-challenge1 as a base where the user is prompted for integer input. Your task is to write a loop that repeats based on user input. Each time the loop repeats, output a single hyphen character. So if the user types in 50, the program generates 50 hyphens a line across the text screen. Use the putchar function to output the hyphen character. You are to write two solutions to this challenge. The first solution uses a for loop. The second solution performs the same task, but with a while loop. This challenge should take about 15 minutes to complete.

Contents