C Program Of Adding Two No.Using Function Without Argument And Return Value

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

#include<stdio.h>

int add(void);       //function declaration

main()
{

 int Add;

  Add=add();       //function call (main function not passing any value to function add).bcuz argument type void

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

  printf("\n\n");

 }

int  add(void)     //function definition (If declaration of Function definition before function main() then no need of function declaration

 {
   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=a+b;    //add both a and b

   return c;     //used bcuz return type is int so value passed to function main where function add() called
 }


Related Posts