| 1. |
What is a subroutine? How do subroutines help in program writing? |
|
Answer» A subroutine is a named, independent section of C code that performs a specific task and optionally returns a value to the calling program. Some of the important characteristics of subroutine that help in program writing are: • A subroutine is named, each have a unique name. By using that name in another part of the program, one can execute the statements contained in the subroutine. • A subroutine is independent that can perform its task without interference from or interfering with other parts of the program. • A subroutine performs a specific task. A task is a discrete job that a program must perform as part of its overall operation, such as sending a line of text to a printer, sorting an array into numerical order, or calculating a cube root. • A subroutine can return a value to the calling program. When a program calls a subroutine, then statements it contains are executed. These statements can pass information back to the calling program. |
|