AllAlgorithms / c

Implementation of All ▲lgorithms in C Programming Language
https://github.com/AllAlgorithms/c
MIT License
1.51k stars 520 forks source link

Usage of function #158

Closed cmehra890 closed 3 years ago

cmehra890 commented 4 years ago

What is the the syntax of using function

tyadav4268 commented 3 years ago

syntax for using a function:- let take an example of add function:

  1. int add(int a, int b)
  2. {
  3. return a+b;
  4. } first line tells that the function have to return an integer and takes two integer arguments. this function should be created before int main() or a declaration of this function to be created before int main() function and then this function can be written after the ending of main() function. Declaration of function is also called function prototype. So for the above function the prototype would be:- int add(int, int);