Monday, February 15, 2016

C Program to find the biggest and smallest of three numbers.

/*=================================================================================
**
**  File Name     : bigSmall.c
**  Creation Date : Tue 16 Feb 2016 03:03:35 AM IST
**  Last Modified : Tue 16 Feb 2016 03:20:17 AM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.sit@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**===============================================================================*/

#include<stdio.h>
void main()
{
    printf("\n= = = = = = Big and Small among 3 number = = = = =\n");
    int n1, n2, n3, big, small;
    printf("\nEnter The first number : ");
    scanf("%d", &n1);
    printf("\nEnter The second number : ");
    scanf("%d", &n2);
    printf("\nEnter The third number : ");
    scanf("%d", &n3);

    printf("--------------------------------------------------\n");
    if(n1>n2 && n1>n3)
    {
        big=n1;
    }
    else if(n2 > n3)
    {
        big=n2;
    }
    else
    {
        big=n3;
    }
    printf("\nThe biggest number is : %d\n",big);
    if(n1<n2 && n1<n3)
    {
        small= n1;
    }
    else if(n2 < n3)
    {
        small = n2;
    }
    else
    {
        small=n3;
    }
    printf("\nThe smallest number is : %d\n",small);
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}

Output :

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

= = = = = = Big and Small among 3 number = = = = =

Enter The first number : 34

Enter The second number : 23

Enter The third number : 67
--------------------------------------------------

The biggest number is : 67

The smallest number is : 23

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

No comments:

Post a Comment