what is function in c and c++?

1 Like

A function is a block of code that has a name and it has a property that it is reusable i.e. it can be executed from as many different points in a C Program as required.

int sum(int x, int y)
int ans = 0; //holds the answer that will be returned
ans = x + y; //calculate the sum
return ans //return the answer