Sponsored Links


Results 1 to 2 of 2

Thread: Q: What is the difference between function declaration and function define with exp

  1. #1
    sana.pari
    Guest

    Icon14 Q: What is the difference between function declaration and function define with exp

    Sponsored Links1



  2. #2
    Dear Student,
    A function declaration is like a variable declaration; its purpose is simply to provide the compiler with all the information it needs for that particular function which we want to use in our program. The compiler does not need to know how the function works (its body). It only needs to know the function’s name, the number and types of its parameters, and its return type. This is precisely the information contained in the function’s declaration. Suppose we have a function which takes two integer type values and then return their sum which is also in integer type so its function declaration is given below:

    int sum(int, int);

    looking at the above function declaration, we can know that this function named "sum" takes two arguments of integer type and return an integer type value. Function declaration is also called function prototype.

    On the other hand, Function definitions differ from function declarations in that they supply function bodies — the code that makes up the function. Function definition for above mentioned is given below:

    int sum(int a, int b)
    {
    int c = a + b;
    return c;
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 05-31-2012, 01:46 AM
  2. Replies: 1
    Last Post: 05-31-2012, 01:35 AM
  3. Replies: 0
    Last Post: 05-30-2011, 03:20 PM
  4. Define function in c++ May 2011
    By Vuhelper in forum C++ Programing
    Replies: 0
    Last Post: 05-30-2011, 03:11 PM
  5. Please define function calling in C++?
    By sana.pari in forum C++ Programing
    Replies: 1
    Last Post: 04-24-2011, 05:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft