42.7k views
4 votes
" Is there any difference between subprogram, functions , methods , subroutines and procedures in C/C++?

Kindly explain with examples "

User Ben Crouse
by
8.5k points

2 Answers

3 votes
Yes there is a difference.
User Chase Finch
by
8.9k points
5 votes
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

User Ashis Laha
by
8.8k points