functuion in c language

 

Functions :

  • Functions are used to divide a large C program into smaller pieces.
  • Function can be called multiple or several times to provide reusability and modularity to the C program.
  • Functions are also called as procedure or subroutines.
  • It is a piece of code to accomplish certain operation

Advantages of Functions :

  • We can avoid rewriting same logic or code through functions.
  • We can divide the work among programmers using functions.
  • We can easily debug or can find bugs in any program using functions.

Function Aspects :

There are 3 aspects of function :-

  1. Declaration
  2. Definition
  3. Call

 there two type of function 

1. library function

2. user define function 


in this all doubt is clear 

#include<stdio.h>
int sum ( int a , int b)
{
   return a+b;
}

int printstarint n )

    
{
   char i;
   
   for (int  i = 0i < 7i++)
   { 
       printf("%c\n",'*');
   }
   
   
    
   
}
int takenumber()
{   
    int i;
    printf(" enter any num\n");
    scanf("%d",&i);
    return i;
}
int main(int argcchar const *argv[])
{
    int abc ,d;
    a = 4;
    b = 5;
    c = sum (a , b);
    printstar(7);
    d = takenumber();
    printf("the sum is %d\n"c);
   printf(" the entered num is %d"d);
    return 0;
}


Comments