C Functions – Create and Run with Examples

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/c-functions-create-run-examples/
PINTEREST
PINTEREST
INSTAGRAM

C Programming Tutorial Index

  1. Introduction To Programming
  2. C Setup Development Environment
  3. C Hello World and Compile First Application
  4. C Syntax and Basics
  5. C Variables
  6. C Numeric Variable Types (Integer, Long, Float)
  7. C String Variables
  8. C Constants and Define Processor
  9. C Operators
  10. C If Else and Switch Case Conditionals
  11. C While Loops
  12. C For Loops
  13. C Arrays
  14. C Functions
  15. C Structure
  16. C Union
  17. C File Operations (Open, Read, Write)
  18. C Pointers
  19. C Type Casting
  20. C Header Files and Include

Functions are a grouping statements to perform operations. Why we group statements in a function? While developing applications same operations can be done thousand of times and writing same code a lot of time is not efficient and exiting. Also changing single statement will require all of the copied statements to change. Every C applications have at least one function which is the entrance function named main() . Below we can see the syntax of the function.

  • return_type defined what type of data will be return with return variable; line. As an example if we return integer we should set return_type as int and put integer variable or value as return variable;
  • function_name is the name of the function and will be used while calling the function. Function names have similar restrictions to the variables.
  • (parameter_list) parameter list provides required variables for the function. Parameter_list is used while calling function with its name.
  • statements is the steps will be done while running inside a function. Function is implemented in the statements part.

Defining Function

Now we will create a simple function named sum which will sum two integer and return result. We can also expand this application by adding divide,multiply, subtract functions as a calculator.

LEARN MORE  Python Class Tutorial with Examples

Return Types

Calling Functions

Function Arguments

Call By Value and Call By Reference

C Programming Tutorial Index

  1. Introduction To Programming
  2. C Setup Development Environment
  3. C Hello World and Compile First Application
  4. C Syntax and Basics
  5. C Variables
  6. C Numeric Variable Types (Integer, Long, Float)
  7. C String Variables
  8. C Constants and Define Processor
  9. C Operators
  10. C If Else and Switch Case Conditionals
  11. C While Loops
  12. C For Loops
  13. C Arrays
  14. C Functions
  15. C Structure
  16. C Union
  17. C File Operations (Open, Read, Write)
  18. C Pointers
  19. C Type Casting
  20. C Header Files and Include
RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/c-functions-create-run-examples/
PINTEREST
PINTEREST
INSTAGRAM

Leave a Reply

Your email address will not be published.