Answers ( 1 )

  1. 15 Mar 2025

    Define function :- A function is a block of code that performs a specific task and can be use multiple times in a program. Functions help in organiz code efficiently by breaking it into small parts.

    Advantages function : 

    Code Reusability :- The same function multiple times without writing the same code again. Instead of repeating code, you just call the function whenever needed.

    Modularity :- functions divide a program into smaller parts, making it easier to understand, fix errors, and update without affecting the whole program.

    Function declar :- A function is declared using a specific syntax, depending on the programming language. In C, a function is declared as follows:

    return_type function_name(parameter_list) {
     // Function body     
    return value;    
    }
    

    Eg. 

    #include <stdio.h>
    
    int add(int a, int b);
    
    int main() {
    
     int result = add(5, 3); 
    
     printf("Sum: %d", result);
    
         return 0;
    }
    int add(int a, int b) {    
     return a + b;
    }

    Here, add() is a function that takes two integers as input and returns their sum.

    3

Leave an Answer


sahebali

Ask by sahebali

Ask Me As you like.

 Prev question

Next question