Web Analytics

" Is there any difference between subprogram, functions , methods , subroutines and procedures in C/C++?

Kindly explain with examples "

Verified Answer :

Yes there is a difference.  

Well let me explain this to you in a better way. The terms 'subprogram', 'function' and 'method' have all the same meaning in C/C++ but we usually called them functions, and we divide the functions into two types :

1)Function : it's the usual one, as we all know, it returns a value.

  2) General format :

  Type function_name(<arguments>){

               // Your work

               return <value/variable> //Note : the type must be the same as the function
                                                    // type.
}

      Example :
int Maheen(int a, int b){
             int c = a + b;

            return c;
        }

 Procedure : it's a function but it doesn't return any value, it begins with 'void'.


General format :

       void function_name(<arguments>){

               // Your work

               //Note : There is no return here.

       }
       
Example :

       void Maheen(int a, int b){
             int c = a + b;

            printf("The sum is : %d", c);
        }

I think this can help you greatly