Jump to content

Find the greatest number from 3 integers using C

From IdeaWazaWiki
Revision as of 16:06, 30 January 2007 by wikademia>Mickraus (main ANSI/ISO conformant; reformatted)
#include<stdio.h>

/* main: display largest of three unequal values */
int main(void)
{
    int a, b, c;
    printf("enter three unequal integers: ");
    scanf("%d%d%d", &a, &b, &c);
    printf("%d", (a > b ? a : b) > c ? (a > b ? a : b) : c);

    /* indicate success */
    return 0;
}