Function with arguments and no return values - C Programming
Addition of two numbers.
/* C Program for addition of two numbers */
#include <stdio.h>
main()
{
void add(int, int); /* Local definition */
int a,b;
printf("Enter two values: ");
scanf("%d %d", &a,&b);
add(a,b); /* add is a function with arguments */
} /* main */
void add(int x, int y) /* add is a function with no return values */
{
/* Local definition */
int z;
/* Statements */
z=x+y;
printf("Sum is..... %d", z);
} /* add */
OUTPUT
Enter two values: 10 20
Sum is..... 30
EXPLANATION: In the program, the arguments a and b are passed to the add() function. Passed arguments are executed in the calling function block and print the result in the same block. The add() function did not return any values to the main function, but the variables a and b are read from the main function.
Computer Programming C Laboratory: Functions C Programs : Tag: C Programming : - C Program for addition of two numbers (Function with arguments and no return values)