Thread: Declarations

  1. #16
    Registered User
    Join Date
    Nov 2012
    Posts
    11
    ok, im gonna get annoying now, but isnt (int n) n a return value???

  2. #17
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    :heart_attack: :facepalm:

    No, it's ok, you're not to blame...

    A function can take any number of parameters. These parameter, like "int minimum(int a, int b)" where "int a" and "int b" are the parameters, are passed by value, meaning that a copy of each passed value is made before sent to the function. Therefore, it's the input of the function, as opposed to "return" which is the output. ( pointers can overpass this, but don't worry about them yet )
    Devoted my life to programming...

  3. #18
    Registered User
    Join Date
    Nov 2012
    Posts
    11
    im completely lost now. the way my inexperienced eyes see it, main() calls void simon(int n) to perform a calculation, simon performs the calculation using n as the value to RETURN to the main function (which would mean it has a return value), which main uses in one way or another, in this example as an integer (right) in the cout statement of main()?

    If im talking rubbish and that made no sense, please correct me in laymans english lol

    Also, as said in the first post, i just need to read more, or there is a more beginner-friendly book, please tell me
    Last edited by brucey2343; 11-13-2012 at 11:34 AM.

  4. #19
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    "simon" just prints some text along with the value of "n" on the console. I don't get it how can you that as returning something. Anyway, you may want to browse the tutorials of this site, post #2, and start from the beginning.
    Devoted my life to programming...

  5. #20
    Registered User
    Join Date
    Nov 2012
    Posts
    11
    beacuse the void simon function is returning the integer value n to the main function?

  6. #21
    Registered User
    Join Date
    Nov 2012
    Posts
    11
    sorry, my bad, ive just looked over the code again, it doesnt return the integer, the cout is performed on the simon function the goes back to the main fuction. correct? sorry

  7. #22
    Registered User
    Join Date
    Nov 2012
    Posts
    12
    Quote Originally Posted by brucey2343 View Post
    Thanks reaper but as i said, total beginner and everything you jost posted was like speaking french to me Im starting to wonder if i should just give up? I dont seem to be getting any of the basic stuff....
    DONT! i was there at one stage, i have come so far from wondering what the hell does int, long, double, string and the sorts mean, keep it up, things will click and you will get there! TIP, get more than one book, try to get idea's for things from different sources.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Declarations and definitions in C
    By jack1234 in forum C Programming
    Replies: 8
    Last Post: 12-17-2007, 11:24 AM
  2. Declarations
    By slippy in forum C++ Programming
    Replies: 13
    Last Post: 12-01-2007, 05:02 PM
  3. Function declarations
    By ssharish2005 in forum C Programming
    Replies: 9
    Last Post: 10-09-2007, 07:06 AM
  4. portable declarations
    By Marv in forum C Programming
    Replies: 10
    Last Post: 04-12-2007, 04:39 PM
  5. help on declarations
    By robasc in forum C Programming
    Replies: 9
    Last Post: 03-05-2005, 01:50 PM

Tags for this Thread