Add Two No.Using Function With Argument And Return Value

//Add two no.using Function with argument and return value

#include<stdio.h>

int add(int,int);         //function declaration

main()
{

   int a,b,c;

   printf("\n"); //newline

   printf("Enter value of a:");       //user give input
   scanf("%d",&a);

   printf("\n");

   printf("Enter value of b:");      //user give input
   scanf("%d",&b);

   printf("\n");

   c=add(a,b);        //function call (main function passing value of a and b to function add). Here  a and b is actual argument/parameter

   printf("Addition of a and b is:%d",c);

    printf("\n\n");

 }

int add(int x,int y)      //function definition.Here x and y formal argument/parameter bcuz value of a and b copy in x and y respectively
 {
   int z;
 
   z=x+y;     //add both x and y

 return z;        //used bcuz return type is int so value passed to function main where function add() called.This time main also passing value to function add(a,b)

 }


Related Posts