Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ ternary operator

#include <iostream>

int main() 
{
	int value = (1 > 0 ? 12 : 41);
  	/*
    if 1 > 0 then value is 12, else 41
    */
  	int val2 = (1 > 0 ? (2 > 4 ? 42 : 45) : 41); // nested
}
Source by www.cprogramming.com #
 
PREVIOUS NEXT
Tagged: #ternary #operator
ADD COMMENT
Topic
Name
3+2 =