All articles
c

A program to explain FUNCTION WITHOUT ARGUMENTS and WITH RETURN VALUES

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 077

  • Write a program to explain FUNCTION WITHOUT ARGUMENTS and WITH RETURN VALUES

Program

#include <stdio.h>
 
int sum();
 
void main()
{
    int c;
    c = sum();
    printf("Sum = %d", c);
    printf("\n");
}
 
int sum()
{
 
    int a, b;
    printf("Enter two numbers: ");
    scanf("%d %d", &a, &b);
 
    return a + b;
}

Result

Enter two numbers: 4 5
Sum = 9

Comments