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
636
  • Share on Facebook
  • Share on Google+
  • Share on Twitter

Using ? and :

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

Notes

last update: Oct. 26, 2014

Advertisement

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

Other language

  • C++
  • Scala
  • Python
  • JavaScript
  • PHP

Random task

  • Get all remote branches
  • HTTP Get REST endpoint
  • Get element from map
  • Set computer name
  • Reverse string
  • Blog
  • About
  • License