Hi all, I have ran into a wall and was really hoping someone might be able to help me understand with an example.
I'm trying to write a program that simple enough just adds 2 number together from user input. The catch is I need 3 functions to do so.
Function1 (to be called from main) to ask for input of the first number and send it back to main
Function2 (to be called from main) to ask for input of the second number and send it back to main
Then the calculation is so be done in main
Function3 (to be called from main) will be used to display the data from the calculation
I know how to do this without functions but am currently unable to get the data to pass from any of the functions back to the main function.
I have read this chapter in my book (C by discovery, 4th edition, Foster & Foster) about 20 times and do not understand any better, I have also checked google and youtube.
If someone could maybe show an example of how to do this with 1 number I think I will be able to figure out the rest.
Passing data from functions in C
Page 1 of 13 Replies - 138 Views - Last Post: 10 September 2012 - 02:51 AM
Replies To: Passing data from functions in C
#2
Re: Passing data from functions in C
Posted 09 September 2012 - 08:22 PM
Show code that reflects your latest best attempt.
What does this mean?
Quote
but am currently unable to get the data to pass from any of the functions back to the main function
What does this mean?
#3
Re: Passing data from functions in C
Posted 10 September 2012 - 02:45 AM
Read the tutorials in my signature..
#4
Re: Passing data from functions in C
Posted 10 September 2012 - 02:51 AM
Specifically, the Functions tutorials in his signature.
To pass data to/from functions, you need arguments and return values. You'll learn them there.
To pass data to/from functions, you need arguments and return values. You'll learn them there.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|