All articles
c

A program to explain FUNCTION WITH ARGUMENTS and WITHOUT RETURN VALUES

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 076

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

Program

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

Result

Enter two numbers: 4 5
Sum = 9

Comments