The Student Room Group

URGENT

difference between outputting from a program and returning a value? Relating to functions and subroutines perhaps?
Hi there,

While you're waiting for an answer, did you know we have 300,000 study resources that could answer your question in TSR's Learn together section?

We have everything from Teacher Marked Essays to Mindmaps and Quizzes to help you with your work. Take a look around.

If you're stuck on how to get started, try creating some resources. It's free to do and can help breakdown tough topics into manageable chunks. Get creating now.

Thanks!

Not sure what all of this is about? Head here to find out more.
Perhaps you should explain your question more clearly, but if a program has an output that would usually be intended for the end user. If a program returns a value it will usually be so another part of the program (like a function) can use it.

Let's take this simple program written is pseudocode:

main(){
output("Please enter a number")
number input = input_from_keyboard()
number answer = square_number(input)
output("Answer is: " answer)
}
square_number(number input){
number answer = input * input
return answer
}


We're sending some output to the user asking them to input a number. We're then passing that number to another function that does something with it and then returns it to where it was originally called. We then output that number.
Reply 3
URGENT: My homework is late and I don't understand it.
Reply 4
Original post by Planto
URGENT: My homework is late and I don't understand it.


Not hw, checking a past paper question for revision. Teacher is incompetent.
Reply 5
Original post by Push_More_Button
Perhaps you should explain your question more clearly, but if a program has an output that would usually be intended for the end user. If a program returns a value it will usually be so another part of the program (like a function) can use it.

Let's take this simple program written is pseudocode:

main(){
output("Please enter a number")
number input = input_from_keyboard()
number answer = square_number(input)
output("Answer is: " answer)
}
square_number(number input){
number answer = input * input
return answer
}


We're sending some output to the user asking them to input a number. We're then passing that number to another function that does something with it and then returns it to where it was originally called. We then output that number.


Thanks for your help, really helped me understand the question.

Quick Reply

Latest

Trending

Trending