English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Include an example, the answer and example must be simple for someone in year 9's homework. Thank you.

2006-10-22 23:31:14 · 2 answers · asked by Jennie C 1 in Computers & Internet Software

2 answers

Normally I dont do other's homeworks. But I make an exception in your case. Next time go to google and search, ok?.

Subroutines are small independent modules of program which are supposed to perform a particular task and can be called from any point of the main program. See example below which is an algorithm.

procedure computeClassTotal
for each student in studentList
loop
call getTotal(studentNo, studentMarks[10])
...............
...............
next student
end loop
end procedure

function getMarks(studentNo INPUT, studentMarks[10] INPUT)
thisTotal = 0
for each marks in studentMarks[10]
loop
thisTotal = thisTotal + marks
next studentMarks
endloop
return thisTotal
end function

As you can see the function getMarks can be called any number of times with different parameters it will do SAME task with DIFFERENT results based on parameters. There are many types of subroutines but this is just one type.

Hope this helps.

.:Fishie:.

2006-10-22 23:51:04 · answer #1 · answered by Fishie 5 · 0 0

The subroutine(function or method) is a portion of code in a very large program which is independent of the remaining code.If we break a large complicated complex program into smaller pieces then it will be very easy for us to understand and to perform certain tasks.We can call these smaller pieces as the subroutine once you write a sub routine then u can use it any where in the proram in this way here we are increasing the readability of the program and we decreasing the complexity of the program by using these sub routines.

2006-10-23 06:44:23 · answer #2 · answered by venkey 1 · 0 0

fedest.com, questions and answers