Latest web development tutorials

C Exercise Example 46

100 cases of classic C language 100 cases of classic C language

Title: macro #define command exercises.

Program Analysis: None.

Source Code:

//  Created by www.w3big.com on 15/11/9.
//  Copyright © 2015年 本教程. 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 above example output is:

如果值小于 50 程序将终止。

请输入数字:100
该数字的平方为 10000 

请输入数字:5
该数字的平方为 25 

100 cases of classic C language 100 cases of classic C language