Jump to content

function and function calls

- - - - -

  • Please log in to reply
10 replies to this topic

#1
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
Hi :)

Please have a look on this page:
https://docs.google....uthkey=CIyjmI8C

My query is about the diagram. There are two diagram sections: Function and Calling Program. Function contains void func1(), and Calling Program contains func1(), func1(), func1().

Is void func1() a major function which makes calls to func1()?

What does the heading "Calling Program" mean?

Are all the three functions func1() same? If they are, then what's the need for listing func1() three times?

Any other advice. Please help me. Thanks
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
void func1() is the function.

The left diagram is the Calling Function.

The three instances of func1() in the Calling Function are the Function calls.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts

WingedPanther said:

void func1() is the function.

The left diagram is the Calling Function.

The three instances of func1() in the Calling Function are the Function calls.

Thank you, WingedPanther.

Is "Calling Function" the body/code of the function being called? If it is, then why is it called "Calling Function"? Shouldn't it be "Called" Function?

Please guide me. Thanks.
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)

#4
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
I'm pretty sure it is called the "calling" function because it calls that instance of func1(). Or "calling" is a verb in this case. I don't really understand the diagram that much though.
Latinamne loqueris?

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
the function on the left calls func1. It is the function that is calling func1.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
I think I get it now. It appears that the "func1()"s in the "Calling Code" are function declarations, and the diagram shows that the code in there calls that function.
Latinamne loqueris?

#7
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts

WingedPanther said:

the function on the left calls func1. It is the function that is calling func1.

Thanks, WingedPanther. Isn't void func1() the one which is calling func1()? Is there any possibility that the Calling Program a some kind of header file, as I believe mebob points out? Please let me know. Thanks.

mebob said:

I think I get it now. It appears that the "func1()"s in the "Calling Code" are function declarations, and the diagram shows that the code in there calls that function.

Thanks, mebob.
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
void func1() is the DEFINITION of the function.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
Oops lol I noticed my mistake, I was tired last night. In the calling code, it has "func1();" statements; that is what is calling the function. On the right, it shows that function declaration, "void func1()". Sorry about the confusion.
Latinamne loqueris?

#10
fayyazlodhi

fayyazlodhi

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 403 posts
I would like to add that the diagram contains arrows showing transfer of control i.e.

There is a calling program, which calls func1, so program control jumps from left (calling program) to right into the called function (void func1() which is function definition). It executes func1 line by line and once completed, control is transferred BACK TO CALLING PROGRAM and proceed with the next step.

This is repeated throughout the diagram and the primary intention is to develop the notion of sequence of execution of instructions in a program during function calls.

Also note that this applies to single threaded program. Otherwise the arrows could be drastically different assuming we create a new thread with every call.

#11
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
Thanks a lot, everyone. I understand it now.

Best regards
Jackson
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users