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()beforemain()that contains aforloop running 3 times (i = 0; i < 3; i++).Inside the loop, it prints
"-----"followed byendlto move to the next line.In the
main()function, the program callsprintLine()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()beforemain()that contains aforloop running 3 times (i = 0; i < 3; i++).Inside the loop, it prints
"-----"followed byendlto move to the next line.In the
main()function, the program callsprintLine()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.