All articles
c

A program to explain FUNCTION WITH ARGUMENTS and RETURN VALUES

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 078

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

Program

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

Result

Enter two numbers: 4 5
Sum = 9

Comments