C Language: macro definition with parameters

#include <stdio.h>
#define N 2 
#define M N+1 
#define MUN (M+1)*M/2
main(){
	printf("%d\n",MUN);
	//(M+1)*M/2
	//(N+1+1)*N+1/2
	//4*2
	//8
}

【operation result】
Here Insert Picture Description

#include <stdio.h>
#define S(x)  x/x*x
main(){
	int k=6,j=3;
	printf("%d,%d\n",S(k+j),S(j+k));
	//S(k+j)
	//k+j/k+j*k+j
	//6+3/6+3*6+3
	//6+0+18+3
	//27
	
	//S(j+k)
	//j+k/j+k*j+k
	//3+6/3+6*3+6
	//3+2+18+6
	//29 
}

Here Insert Picture Description

Published 31 original articles · won praise 2 · Views 3845

Guess you like

Origin blog.csdn.net/weixin_44652687/article/details/100861446