C Exercise 46
100 Classic C Language Examples
**Problem:** Practice the macro #define command.
**Analysis:** None.
Program source code:
// Created by www.runoob.com on 15/11/9.
// Copyright © 2015 Runoob Tutorial. All rights reserved.
//
#include
#define TRUE 1
#define FALSE 0
#define SQ(x) (x)*(x)
int main()
{
int num;
int again=1;
printf("如果值小于 50 程序将终止。\n");
while(again)
{
printf("\n请输入数字:");
scanf("%d",&num);
printf("该数字的平方为 %d \n",SQ(num));
if(num>=50)
again=TRUE;
else
again=FALSE;
}
return 0;
}
The output of the above example is:
如果值小于 50 程序将终止。
请输入数字:100
该数字的平方为 10000
请输入数字:5
该数字的平方为 25