Solution: Line Printing Function

The main() function calls a separate function named printLine() that prints a simple line pattern multiple times.

  • Defines a function printLine() before main() that contains a for loop running 3 times (i = 0; i < 3; i++).

  • Inside the loop, it prints "-----" followed by endl to move to the next line.

  • In the main() function, the program calls printLine() to execute that printing task.

  • This results in three lines of dashes being displayed on the screen.

  • Ends with return 0; to indicate successful program completion.

Solution: Line Printing Function

The main() function calls a separate function named printLine() that prints a simple line pattern multiple times.

  • Defines a function printLine() before main() that contains a for loop running 3 times (i = 0; i < 3; i++).

  • Inside the loop, it prints "-----" followed by endl to move to the next line.

  • In the main() function, the program calls printLine() to execute that printing task.

  • This results in three lines of dashes being displayed on the screen.

  • Ends with return 0; to indicate successful program completion.