Easy Tutorial
❮ C Function Calloc C Function Strcat ❯

C Exercise Example 46

C Language Classic 100 Examples

Title: Macro #define Command Practice.

Program Analysis: None.

Program Source Code:

//  Created by www.tutorialpro.org on 15/11/9.
//  Copyright © 2015 tutorialpro.org. 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("The program will terminate if the value is less than 50.\n");
    while(again)
    {
        printf("\nPlease enter a number: ");
        scanf("%d",&num);
        printf("The square of the number is %d \n",SQ(num));
        if(num>=50)
            again=TRUE;
        else
            again=FALSE;
    }
    return 0;
}

Output of the above example:

The program will terminate if the value is less than 50.

Please enter a number: 100
The square of the number is 10000 

Please enter a number: 5
The square of the number is 25

C Language Classic 100 Examples

❮ C Function Calloc C Function Strcat ❯