1 Replies - 792 Views - Last Post: 20 March 2011 - 07:41 PM Rate Topic: -----

#1 direwolf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 11-March 11

How to Rewrite C++ statement using the Conditional Operator?

Posted 20 March 2011 - 07:36 PM

I'm not sure how I can rewrite this using the conditional operator, any suggestions? Thanks, direwolf

if (x <= y)
z = x
else
z = y;

This post has been edited by Martyn.Rae: 20 March 2011 - 09:04 PM
Reason for edit:: Code tags to work

Is This A Good Question/Topic? 0
  • +

Replies To: How to Rewrite C++ statement using the Conditional Operator?

#2 TMKCodes  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 48
  • View blog
  • Posts: 440
  • Joined: 21-March 09

Re: How to Rewrite C++ statement using the Conditional Operator?

Posted 20 March 2011 - 07:41 PM

This is the exact same if statement done with the conditional operator.
(x <= y) ? (z = x) : (z = y);


This post has been edited by TMKCodes: 20 March 2011 - 07:41 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1