Add Two No.Using Function With Argument And No Return Value

Add Two No.Using Function With Argument And No Return Value

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

#include<stdio.h>

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

main()
{

   int a,b;

   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");

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

add(a,b);     //Function called again


 }

void  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
 
   printf("Addition of a and b is:%d",z); //print value of z
   printf("\n\n");

// return z; not used bcuz return type is void so no value passed to function main where function add() called.this time main passing value to function add(a,b)
 }


Related Posts