Easy Tutorial
❮ C Function Iscntrl C Examples For Even Odd ❯

C Exercise Example 47

C Language Classic 100 Examples

Title: Macro #define Command Practice 2.

Program Analysis: None.

Program Source Code:

//  Created by www.tutorialpro.org on 15/11/9.
//  Copyright © 2015 tutorialpro.org. All rights reserved.
//

#include<stdio.h>
#define exchange(a,b) { int t;t=a;a=b;b=t;}//Note to keep it in one line
int main()
{
    int x=10;
    int y=20;
    printf("x=%d; y=%d\n",x,y);
    exchange(x,y);
    printf("x=%d; y=%d\n",x,y);
    return 0;
}

The output of the above example is:

x=10; y=20
x=20; y=10

C Language Classic 100 Examples

❮ C Function Iscntrl C Examples For Even Odd ❯