delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/29/01:58:40

Mime-Version: 1.0
To: "Arthur" <arfa AT clara DOT net>, <djgpp AT delorie DOT com>
From: Nate Eldredge <nate AT cartsys DOT com>
Subject: Re: Programming Prob.
Date: Tue, 28 Apr 1998 20:38:15 -0700
Message-ID: <19980429033703.AAP3301@ppp104.cartsys.com>

At 09:00  4/27/1998 +0100, Arthur wrote:

>Surely in C++, it is better to forget the if/then/else construct altogether:
>
>void main(void)
>{
>    int int1,int2,answer;
>
>    printf("Please enter 2 integers.\n");
>    scanf("%i %i",&int1 ,&int2);
>
>    answer = ( (int1 > int2) ? int1 : int2 );
>
>    printf(" The larger integer is %d\n",answer);
>
>}

Additional trivia: If using GNU C++, you can say:

answer = int1 >? int2;

Nate Eldredge
nate AT cartsys DOT com



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019