Powered By Blogger

Friday, December 24, 2010

C Program to find the greater of the 2 numbers

/* C Program to accept two numbers from the user and to print the greater number */

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int num1;
    int num2;
    printf("Enter the First number\n");
    scanf("%d",&num1);
    printf("Enter the Second number\n");
    scanf("%d",&num2);
    if(num1>num2)
    {
        printf("The First number is Greater than the Second number\n");
    }
    else
    {
        if(num1==num2)
        {
            printf("Both the numbers are equal\n");
        }
        else
        {
            printf("The Second number is Greater than the First number\n");
        }
    }
    return 0;
}

No comments:

Post a Comment