Wednesday, September 23, 2015

Using if else construct in C

#include <stdio.h>
#include <conio.h>
void main
{
                clrscr();
                int a;
                printf("Please enter a number: \n");
                scanf("%d",&a);
                if
                                (a<20)
                {
                                printf("%d is less than 20\n", a);
                }
                else
                {
                                printf("%d is greater than 20\n", a);
                }
                getch();
}

Output:  
Please enter a number: 22
22 is greater than 20.

No comments:

Post a Comment