Program to find maximum and minimum of three numbers in C

Program Logic 1

#include<stdio.h>
int main()
{
    int a,b,c,max,min;
    printf("************************************************************");
    printf("\n************************************************************");
    printf("\n** WAP to find maximum and minimum of three numbers in C  **");
    printf("\n**             using if else if laddar                    **");
    printf("\n**              Created by Sheetal Garg                   **");
    printf("\n**              Assistant Professor                       **");
    printf("\n**              Phone No:9467863365                       **");
    printf("\n************************************************************");
    printf("\n************************************************************");
    printf("\nenter three numbers");
    scanf("%d%d%d",&a,&b,&c);
    if(a>b && a>c)
    max=a;
    else if (b>a && b>c)
    max=b;
    else if (c>a && c>b)
    max=c;
    printf("maximum is %d",max);
    if(a<b && a<c)
    min=a;
    else if (b<a && b<c)
    min=b;
    else if (c<a && c<b)
    min=c;
    printf("\nminimum is %d",min);
    return 0;
}

Output

************************************************************
************************************************************
** WAP to find maximum and minimum of three numbers in C  **
**             using if else if laddar                    **
**              Created by Sheetal Garg                   **
**              Assistant Professor                       **
**              Phone No:9467863365                       **
************************************************************
************************************************************
enter three numbers
6
7
8
maximum is 8
minimum is 6

Program Logic 2

#include<stdio.h>
int main()
{
    int a,b,c,max,min;
    printf("************************************************************");
    printf("\n************************************************************");
    printf("\n** WAP to find maximum and minimum of three numbers in C  **");
    printf("\n**             using if else if laddar                    **");
    printf("\n**              Created by Sheetal Garg                   **");
    printf("\n**              Assistant Professor                       **");
    printf("\n**              Phone No:9467863365                       **");
    printf("\n************************************************************");
    printf("\n************************************************************");
    printf("\nenter three numbers");
    scanf("%d%d%d",&a,&b,&c);
    if(a>b && a>c)
    max=a;
    else if (b>c)
    max=b;
    else
    max=c;
    printf("maximum is %d",max);
    if(a<b && a<c)
    min=a;
    else if (b<c)
    min=b;
    else
    min=c;
    printf("\nminimum is %d",min);
    return 0;
}

Output

************************************************************
************************************************************
** WAP to find maximum and minimum of three numbers in C  **
**             using if else if laddar                    **
**              Created by Sheetal Garg                   **
**              Assistant Professor                       **
**              Phone No:9467863365                       **
************************************************************
************************************************************

enter three numbers
6
7
8
maximum is 8
minimum is 6

Program Logic 3

#include <stdio.h>
int main()
{
    int a, b, c, max, min;
    printf("************************************************************");
    printf("\n************************************************************");
    printf("\n** WAP to find maximum and minimum of three numbers in C  **");
    printf("\n**             using nested if else                       **");
    printf("\n**              Created by Sheetal Garg                   **");
    printf("\n**              Assistant Professor                       **");
    printf("\n**              Phone No:9467863365                       **");
    printf("\n************************************************************");
    printf("\n************************************************************");
    printf("\nenter three numbers");
    scanf("%d%d%d", &a, &b, &c);
    if (a > b)
    {
        if (a > c)
            max = a;
        else
            max = c;
    }
    else
    {
        if (b > c)
            max = b;
        else
            max = c;
    }
    printf("maximum is %d", max);
    if (a < b)
    {
        if (a < c)
            min = a;
        else
            min = c;
    }
    else
    {
        if (b < c)
            min = b;
        else
            min = c;
    }
    printf("\nminimum is %d", min);
    return 0;
}

Output

************************************************************
************************************************************
** WAP to find maximum and minimum of three numbers in C  **
**             using nested if else                       **
**              Created by Sheetal Garg                   **
**              Assistant Professor                       **
**              Phone No:9467863365                       **
************************************************************
************************************************************
enter three numbers
9
5
16
maximum is 16
minimum is 5

Program Logic 4

#include <stdio.h>
int main()
{
    int a, b, c, max, min;
    printf("************************************************************");
    printf("\n************************************************************");
    printf("\n** WAP to find maximum and minimum of three numbers in C  **");
    printf("\n**             using conditional operator                 **");
    printf("\n**              Created by Sheetal Garg                   **");
    printf("\n**              Assistant Professor                       **");
    printf("\n**              Phone No:9467863365                       **");
    printf("\n************************************************************");
    printf("\n************************************************************");
    printf("\nenter three numbers");
    scanf("%d%d%d", &a, &b, &c);
    max=(a>b)?(a>c?a:c):(b>c?b:c);
    min=(a<b)?(a<c?a:c):(b<c?b:c);
    printf("maximum is %d", max);
    printf("\nminimum is %d", min);
    return 0;
}

Output

************************************************************
************************************************************
** WAP to find maximum and minimum of three numbers in C  **
**             using conditional operator                 **
**              Created by Sheetal Garg                   **
**              Assistant Professor                       **
**              Phone No:9467863365                       **
************************************************************
************************************************************
enter three numbers
8
7
5
maximum is 8
minimum is 5
error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.