Site menu

CodeCook.io

  • Languages
    • C
    • C++
    • CSS
    • Git
    • HTML
    • Java
    • JavaScript
    • jQuery
    • PHP
    • Python
    • Ruby
    • Scala
  • control
  • if
  • ternary

C++ - Inline conditional

Execute one or other code block depending on condition in a single line. This ternary conditional code is shorter than explicit if statements.

0
572
  • Share on Facebook
  • Share on Google+
  • Share on Twitter

Using ? and :

{{condition}} ? {{true_code}} : {{false_code}};
cpp

Notes

last update: Oct. 27, 2014

Advertisement

This project is hosted on DigitalOcean, try it and support us

Other language

  • Scala
  • Python
  • JavaScript
  • C
  • PHP

Random task

  • Inline conditional
  • Search apt package
  • Random number
  • Random element from queryset
  • Run docker daemon container
  • Blog
  • About
  • License