Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Nested ternary operator C++

/*
Syntax : op1 ? op2 : op3;
Nested Ternary operator: Ternary operator can be nested. 
A nested ternary operator can have many forms like : 

a ? b : c
a ? b: c ? d : e ? f : g ? h : i
a ? b ? c : d : e

*/
// nested ternary operators
#include <bits/stdc++.h>
using namespace std;
    
int main()
{
    cout << "Execute expression using"
    << " ternary operator: ";
    // Execute expression using
    // ternary operator
    int a = 2 > 5 ? 2 : 5;
    cout << a << endl;
        
    cout << "Execute expression using "
    << "if else statement: ";
        
    // Execute expression using if else
    if ( 2 > 5)
        cout << "2";
    else
        cout << "5";
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: sfml time set 
Cpp :: find node from pos linkedlist c++ 
Cpp :: c++ to mips assembly converter 
Cpp :: c# unity rendering object 
Cpp :: unreal engine c++ bind action to function with parameter 
Cpp :: delete[] cpp 
Cpp :: sleep function i nc++ 
Cpp :: cpprestsdk header 
Cpp :: c++ enter name and surname one string 
Cpp :: deliberation meaning 
Cpp :: punteros a arrays 
Cpp :: fibonacci sequence c++ 
Cpp :: the statement vector vector int matrix(100 vector int (50 100) ) declares 
Cpp :: set keybinding for compiling c++ program in neovim 
Cpp :: ue4 execute delegate from blueprint 
Cpp :: The smallest element from three 
Cpp :: convert string to wide string 
Cpp :: std::hash 
Cpp :: how to show c++ binary files in sublime text 
Cpp :: c++ FAILED: objekt aufruf : symbol(s) not found for architecture x86_64 
Cpp :: c++ starting syntaz 
Cpp :: beecrowd problem 1004 solution 
Cpp :: how to run c++ on cmd 
Cpp :: can derived class access base class non-static members without object of the base class 
Cpp :: how to use printf with microseconds c++ 
Cpp :: online c++ graphics compiler 
Cpp :: converter python to c++ code 
Cpp :: qrandomgenerator bounded 
Cpp :: max stack 
Cpp :: Determine if map contains a value for a key c++ 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =