Thread: What is Implicit and Explicit Arguments in C programming

  1. #1
    Registered User
    Join Date
    Aug 2015
    Location
    India
    Posts
    14

    What is Implicit and Explicit Arguments in C programming

    I don't know what these terms stands for. Please Explain these terms using below code. If possible please provide syntax how pass argument implicitly and explicitly.
    Code:
    #include<stdio.h>
    int add (int, int);            // function prototype 
    int main()
    {
        int a = 10, b = 20, sum;
        sum = add(a,b);                   // function call
        printf("Addition = %d", sum);
    }
    int add (int x, int y)              // function definition 
    {
        int total;
        total = x+y;
        return (total);
    }

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    If possible please provide syntax how pass argument implicitly and explicitly.
    Okay, but remember that the current C standard doesn't allow implicit parameter types.

    Your program is using explicit parameter and return types. Implicit follows (note using C98 standard):

    Code:
    #include<stdio.h>
    
    /* Notice no function prototype */
    int main()
    {
        int a = 10, b = 20, sum;
        sum = add(a,b);
        printf("Addition = %d", sum);
    
        /* In C98 you should explicitly return an int from this function
            the compiler doesn't implicitly return zero, unlike the current 
            standard. 
    
        Also note that the C98 standard doesn't allow C++ type of comments.
    
        */
        return 0;
    }
    
    /* Implicit return type and implicit type for x. Explicit type for y. */
    add (x, int y)  
    {
        int total;
        total = x + y;
        return (total);
    }
    Because of the lack of a function prototype the compiler will assume that the function returns an int, that there can be any number of arguments, and that all the arguments will be of type int. This is referred to as an implicit function declaration.

    Now to the function implementation. By removing the explicit return type you now have an implicit return type, the compiler will assume the function returns an int. The same with the implicit parameter, the compiler will also assume that the argument is of type int.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mixing implicit and explicit template arguments
    By Mozza314 in forum C++ Programming
    Replies: 7
    Last Post: 01-21-2011, 06:44 PM
  2. Help with implicit and explicit constructor calls
    By mborba22 in forum C++ Programming
    Replies: 1
    Last Post: 09-22-2010, 03:49 PM
  3. implicit/explicit? conversion of classes?
    By what3v3r in forum C++ Programming
    Replies: 7
    Last Post: 01-31-2006, 07:08 PM
  4. Implicit and Explicit
    By ripper079 in forum C++ Programming
    Replies: 2
    Last Post: 09-06-2002, 12:22 PM
  5. implicit explicit
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 01-22-2002, 04:10 AM

Tags for this Thread