Search
 
SCRIPT & CODE EXAMPLE
 

CPP

conditional operator in cpp

//(expression 1) ? expression 2 : expression 3
//If expression 1 evaluates to true, then expression 2 is evaluated.
   int x, y = 10;

   x = (y < 10) ? 30 : 40;
   cout << "value of x: " << x << endl; //prints 40
 
   
Comment

conditional operator in c++

 // syntax
condition ? inline code for ture condition : inline code for false condition;

3 > 2 ? true : false; // return true
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to round a double to 2 decimal places in c++ 
Cpp :: wine linux 
Cpp :: how to copy one vector to another 
Cpp :: parallelize for loop c++ 
Cpp :: 2d vector cpp 
Cpp :: iff arduino 
Cpp :: how to read and parse a json file with rapidjson 
Cpp :: c++ check if char is number 
Cpp :: how to round to nearest whole number unity 
Cpp :: cpp unions 
Cpp :: string length c++ 
Cpp :: c++ return multiple values 
Cpp :: c++ length of char array 
Cpp :: C++ Swap 2 Variables Without Using 3rd Variable 
Cpp :: terminal compile c++ 
Cpp :: remove last index of the string in c++ 
Cpp :: check uppercase c++ 
Cpp :: udo apt install dotnet-sdk-5 
Cpp :: string to char* 
Cpp :: delete specific row from dynamic 2d array c++ 
Cpp :: how to get the size of a vector in c++ 
Cpp :: convert decimal to binary in c++ 
Cpp :: c++ string element access 
Cpp :: remove from vector by value c++ 
Cpp :: c++ lambda 
Cpp :: c++ fstream create if not exists 
Cpp :: union of two arrays leetcode 
Cpp :: image shapes in opencv c++ 
Cpp :: float to int c++ 
Cpp :: c++ reverse string 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =