Monday, February 15, 2016

C Program to find max and min between two numbers.

/*=================================================================================
 **
 **  File Name     : maxmin.c
 **  Creation Date : Tue 16 Feb 2016 01:09:26 AM IST
 **  Last Modified : Tue 16 Feb 2016 02:33:46 AM IST
 **  Compoler      : gcc
 **  Author        : Manoj Kumar Patra, manojpatra.sit@gmail.com
 **  Organization  : SCIS, University of Hyderabad, India.
 **
 **===============================================================================*/

#include<stdio.h>
int main() 
{
    printf("\n= = = = = = Find max and min between two numbers = = = = = =\n\n");
    int num1, num2; 
    printf("Enter the first numbers : "); 
    scanf("%d", &num1); 
    printf("Enter the second numbers : "); 
    scanf("%d", &num2); 
    if(num1 > num2) 
    { 
        printf("\n%d is Maximum.\n", num1);
        printf("%d is Minimum.\n",num2);
    } 
    else 
    { 
        printf("\n%d is maximum.\n", num2); 
        printf("%d is Minimum.\n",num1);
    } 
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
    return 0; 
}

Output :

max@ubuntu:~/cprog$ gcc maxmin.c -o maxmin
max@ubuntu:~/cprog$ ./maxmin

= = = = = = Find max and min between two numbers = = = = = =

Enter the first numbers : 450
Enter the second numbers : 650

650 is maximum.
450 is Minimum.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

No comments:

Post a Comment