Home

A program to explain macros with ARGUMENTS

C Programming Language 097

Program

#include <stdio.h>
#define add(x, y) (x + y)

void main()
{
    int a, b;
    float res;

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

    res = add(a, b);
    printf("Sum = %f", res);

    printf("\n");
}

Result

Enter two numbers: 2 4
Sum = 6.000000


Last Updated on

Next Post: GraphProtocol: TS2322 null assignment in Subgraph →

Comments