groups

name language licence
Equation array Latex Other
enum - array of labelled values C++ Other
Print a TCut C++ Other
Reading and writing TEvent's C++ Other
Maximum for a histogram when plotting C++ Other
Untitled Snippet Other Other
Ternery operator / conditional expression C++ Other
Change user group of a file Shell Other

< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 >



language: C++
licence: Other

Ternery operator / conditional expression

options: view full snippetsend to code collector

// Syntax :

variable = condition ? value if true : value if false

// Using the ? operator :

int opening_time = (day == WEEKEND) ? 12 : 9;

// Without using the ? operator :

int opening_time;
 
if (day == WEEKEND)
    opening_time = 12;
	
(Continues...)