Function Passing No Arguments and Returning Values

Function Passing no Arguments and Returning Values

This program describes how to write function passing no arguments and returning values.

#include <stdio.h>
#include <conio.h>

int sum (void);

void main()
{
int c;
c=sum();
printf("n The sum of two numbers is : %d",c);
getch();
}
int sum(void){
int add, a, b;

printf("Enter two numbers:");
scanf("%d%d",&a,&b);

add=a+b;

return(add);
}

Output

Function Passing no Arguments and Returning Values