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

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

#include<stdio.h>

void add(void);    //function declaration

main()
 {

 add();     //function call (main function not passing any value to function add)

 }

void  add(void)    //function definition
 {

   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
 
   printf("Value of c is:%d",c);    //print value of c
  
   printf("\n\n");

  // return c;  not used bcuz return type is void so no value passed to function main where function add() called

 }


Related Posts