+1 vote

1 Answer

0 votes
selected by
Best answer

To save you from rewriting lots of code again and again you might use a sub-routine, there are two types: Procedures and Functions. For example in a program you wanted to know today's date, instead of having to write a separate sub routine to calculate the date and time you wanted to work out, you would probably use date(). This is a function, when you call it, it returns a value. It was written by someone else and you can keep using it as many times as you want. Any program written in industry will use sub routines calling things like: console.writeline(), printScore(), deleteRecord(). Procedures and Functions allow for you to:

  • Reuse code
  • Structure your programming
  • Easily incorporate other people's code
An easy way to tell the difference between a Procedure and a Function is to look at the names:
  • Functions are fun: if you would call them, they would return a value
  • Procedures aren't fun: if you call them they don't return any value. (these are known as sub in Visual Basic).

Related questions

Welcome to CPEN Talk
Solution-oriented students of computer engineering on one platform to get you that


Chuck Norris doesn't do Burn Down charts, he does Smack Down charts.