Launch your tech mastery with us—your coding journey starts now!
Course Content
Basic Syntax and Data Types
0/2
Arrays and Strings
0/2
Structures in C
0/1
Dynamic Memory Management
0/1
Command Line Arguments
0/1
Preprocessor Directives
0/1
C Programming

Syntax of a User-Defined Function:

return_type function_name(parameter_list) {

   // body of the function

}

Example:

void greet() {

   printf(“Hello, Welcome!”);

}

To call it:

greet();

   Function with Parameters and Return:

int add(int a, int b) {

   return a + b;

}

Function Call:

int result = add(5, 3);

Function Types (Based on Arguments and Return Values):

Function Type

Example

No arguments, no return

void greet()

With arguments, no return

void display(int x)

No arguments, with return

int getValue()

With arguments, with return

int add(int a, int b)