Functions in C

  • Post author:
  • Post category:c
  • Post comments:0 Comments

Functions in C

In this lesson, you will learn about the different types of functions that can be used in C programming. Functions are used to modularize code and make it easier to read and maintain. You will learn about function declarations, function calls, parameter passing, and the different types of functions available, such as built-in and user-defined.

Example

#include <stdio.h> 

int add(int a, int b); 

int main() 
{ 
    int a = 10; 
    int b = 20; 
    int c; 
  
    c = add(a, b); 
  
    printf("The sum of %d and %d is %d", a, b, c); 
    return 0; 
} 

int add(int a, int b) 
{ 
    int c; 
  
    c = a + b; 
  
    return c; 
} 

Output

The sum of 10 and 20 is 30

Leave a Reply