Computer Programming C Laboratory: Functions C Programs

C Program to addition of two numbers (Function with no arguments and no return values)

Function with no arguments and no return values - C Programming

Addition of two numbers.

/* C Program to addition of two numbers */

#include <stdio.h>

main()

{

      void add(void);

      add(); /* add is a function with no arguments */

} /* main **/

void add()

{

      int a, b, c ; /** Local definitions */

      /* Statements */

      printf("Enter two numbers...");

      scanf("%d %d",&a, &b);

      c=a+b:

      printf("Sum is... %d",c);

} /* add */

OUTPUT

Enter two numbers... 10 20

Sum is... 30

EXPLANATION: In the above program, user‒defined function add() is defined. The main function calls the add() function. The user‒defined function add() executed the block of statements and prints the output in same block. There is no argument sent from main function and no values are returned from the add() function.


Computer Programming C Laboratory: Functions C Programs : Tag: C Programming : - C Program to addition of two numbers (Function with no arguments and no return values)


Computer Programming C Laboratory: Functions C Programs



Under Subject



Related Subjects