linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ternary operator
@ 2005-06-28 17:22 Vadiraj
  2005-06-28 17:44 ` Ron Michael Khu
  2005-06-28 17:49 ` Steve Graegert
  0 siblings, 2 replies; 7+ messages in thread
From: Vadiraj @ 2005-06-28 17:22 UTC (permalink / raw)
  To: linux-c-programming

Hi List,

 I'm confused with the behavior of this program..

func4()
{
    return 3;
}
func3()
{
    return 2;
}
func2()
{
}

func1()
{
    return(func2()?func3():func4()) ;
}
int main()
{
     
     printf("%d\n",func1() ) ;                       // this prints 3
     printf("%d\n",func2()?func3():func4()) ;  // this prints 2
}

 I dont understand whats making the two statements to behave differently.



-- 
cheers,
Vadi

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-06-28 18:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-28 17:22 ternary operator Vadiraj
2005-06-28 17:44 ` Ron Michael Khu
2005-06-28 17:49 ` Steve Graegert
2005-06-28 17:15   ` Luiz Fernando Capitulino
2005-06-28 18:24     ` Steve Graegert
2005-06-28 18:24   ` Vadiraj
2005-06-28 18:47     ` Steve Graegert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).