Notices
Results 1 to 7 of 7

Thread: a c++ question.plz help me understand this concept...functio

  1. #1 a c++ question.plz help me understand this concept...functio 
    Forum Freshman
    Join Date
    Nov 2009
    Posts
    11
    i'm a student of programming (b.sc)... In my textbook of C++ it is written in the def. Of function call,that function call is a type of statement that moves the control to another block of codes.what does it mean by block of codes? Explain.and also plz explain what is the difference bet.a statement and an instruction?


    Reply With Quote  
     

  2.  
     

  3. #2  
    Forum Freshman DrNesbit's Avatar
    Join Date
    Nov 2009
    Location
    Supermegatopian Labs
    Posts
    98
    Look up all terms you don't understand on Wikipedia.

    Install a C++ compiler (gcc, or a development environment), play around with it writing simple command-line programs doing things like interactively asking the user to guess a (random) number. Something like:
    Guess the magic number between 0 and 100
    > 50
    too low
    > 80
    too high
    > 60
    too high
    > 55
    too high
    > 52
    too low
    > 53
    correct!
    Or, if that seems like to much work, you may consider careers more appropriate to your understanding of computers.


    Reply With Quote  
     

  4. #3  
    Forum Bachelors Degree
    Join Date
    Mar 2009
    Posts
    421
    Quote Originally Posted by DrNesbit
    Or, if that seems like to much work, you may consider careers more appropriate to your understanding of computers.
    Is it absolutely necessary to be a jerk to people?
    Reply With Quote  
     

  5. #4  
    Forum Freshman DrNesbit's Avatar
    Join Date
    Nov 2009
    Location
    Supermegatopian Labs
    Posts
    98
    Not absolutely necessary, I was probably a bit harsh.

    I'm probably biased against people who expect other forum users to do their homework for them (though I'm not sure that's the case here), and future bad programmers. The world has enough buggy code as it is, and I honestly think that for someone who doesn't seem very self-motivated or curious about computers, there are better career choices than computer science.
    Reply With Quote  
     

  6. #5 Re: a c++ question.plz help me understand this concept...fun 
    Forum Sophomore CShark's Avatar
    Join Date
    May 2008
    Location
    East Coast of Canada
    Posts
    192
    Quote Originally Posted by m.khan
    i'm a student of programming (b.sc)... In my textbook of C++ it is written in the def. Of function call,that function call is a type of statement that moves the control to another block of codes.what does it mean by block of codes? Explain.and also plz explain what is the difference bet.a statement and an instruction?
    FWIW, I've been working in VC++ for 12 years, and I have no idea what 'block of codes' is... Perhaps the function returns the address of another function ? Sorry I can't be of more help.

    Merry Christmas
    Reply With Quote  
     

  7. #6  
    Forum Ph.D. Leszek Luchowski's Avatar
    Join Date
    Jun 2008
    Location
    Gliwice, Poland
    Posts
    807
    I am almost sure that the book meant "block of code", not "block of codes".

    And what they mean by a block of code is probably a part of a program that is, or can be without change of meaning, enclosed in curly braces {}.

    Very roughly, it's just any part of the program that makes sense in itself. A function is one type of such a block.

    A function call transfers control to another block of code - this means that, when the computer is executing some block of code (such as the main program, or a function) and runs into a function call, it will stop executing that block and start executing the function that was called.

    Upon completion of that function the computer will return to the first block (say, the main program) and resume its execution at the next statement after the call.

    Hope this helps.
    Leszek. Pronounced [LEH-sheck]. The wondering Slav.
    History teaches us that we don't learn from history.
    Reply With Quote  
     

  8. #7  
    Forum Freshman
    Join Date
    Nov 2009
    Posts
    8
    i think they chose to call it block of code because a functions's parameters are variables local to the function and other calculations and a return statement making it seem like a mini program in itself(collection of data and code). resembling what classes are in OOP at a structural point of wiew.
    ive taken C++ course and currently attending OOP java can't come up with a better answer
    Reply With Quote  
     

Bookmarks
Bookmarks
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •