Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
oorrja
GitHub Repository: oorrja/learntosolveit
Path: blob/master/languages/cprogs/Ex_4.14_swap_t_x_y.c
1240 views
1
/* a macro swap(t,x,y) that interchanges two arguments of type t */
2
3
#include<stdio.h>
4
5
#define swap(t,x,y) { t _z; \
6
_z = x;\
7
x = y;\
8
y = _z; }
9
10
int main(void)
11
{
12
char x,y;
13
x='a';
14
y='b';
15
printf("x= %c \t y= %c\n",x,y);
16
swap(char,x,y);
17
printf("x=%c \t y=%c\n",x,y);
18
}
19
20
21
22