Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ terinary operator

// format = condition ? expression1 : expression2;
#include <iostream>
#include <string>
using namespace std;

int main() {
  double marks;

  // take input from users
  cout << "Enter your marks: ";
  cin >> marks;

  // ternary operator checks if
  // marks is greater than 40
  string result = (marks >= 40) ? "passed" : "failed";

  cout << "You " << result << " the exam.";

  return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: passing reference to thread c++ 
Cpp :: Link List Insertion a node 
Cpp :: array di struct 
Cpp :: how to install open cv2 in c++ on ubuntu 
Cpp :: ue4 c++ enum variable declaration 
Cpp :: stl map 
Cpp :: how to save system function output into a variable in c++ 
Cpp :: integrate sinx 
Cpp :: how to run the code 
Cpp :: CPP Find options passed from command line 
Cpp :: assegnare valori in c++ 
Cpp :: c++ schleife abbrechen 
Cpp :: Buy 2 Get 1 Free codechef solution in c++ 
Cpp :: c++ tuple example 
Cpp :: for llop in c++ 
Cpp :: float to byte array and back c++ with memcpy command 
Cpp :: convert c program to c ++ online 
Cpp :: quiz arrary and pointers in c++ 
Cpp :: Arduino C++ servomotor random moving 
Cpp :: stp 
Cpp :: can you use rand to read in from an external file inc++ 
Cpp :: c++ CRL multiline string 
Cpp :: lnk2001 unresolved external symbol __imp_PlaySoundA 
Cpp :: is plaindrome 
Cpp :: c++ loop 
Cpp :: backward chaining python 
Cpp :: csv 
Cpp :: icon on win32 button 
Cpp :: c++ arreglo/array 
Cpp :: how to get the numbers in a vector c++ sfml 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =