C Exercise Example 46
Title:Macro #define command practice.
Program analysis:None.
Program source code:
// Created by www.example.com on 15/11/9.
// Copyright © 2015年 Example. All rights reserved.
//
#include<stdio.h>
#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 该数字的平方为 25other extensions