Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Highest integer among the four inputs in c

#include<stdio.h>

int getBest(int a, int b, int c, int d);

int main(void) {
    int a, b, c, d;

    printf("Enter a: ");
    scanf("%d", &a);

    printf("Enter b: ");
    scanf("%d", &b);

    printf("Enter c: ");
    scanf("%d", &c);

    printf("Enter d: ");
    scanf("%d", &d);

    int highest = getBest(a, b, c, d);

    printf("Highest integer = %d", highest);

    return 0;
}

int getBest(int a, int b, int c, int d){
  
  if ( !( a < b || a < c || a < d ) )
    {        
        return a;
    }        
    else if ( !( b < c || b < d ) )
    {        
        return b;
    }        
    else if ( !( c < d ) )
    {        
        return c;
    }        
    else 
    {        
        return d;
    }
}
 
PREVIOUS NEXT
Tagged: #Highest #integer #inputs
ADD COMMENT
Topic
Name
7+1 =