🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 34 (from laksa192)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
24 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.8 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.dremendo.com/cpp-programming-tutorial/cpp-conditional-operator
Last Crawled2026-03-23 16:09:01 (24 days ago)
First Indexed2020-11-17 10:11:11 (5 years ago)
HTTP Status Code200
Meta TitleConditional Operator in C++ Programming | Dremendo
Meta DescriptionConditional Operator in C++ returns one value if the condition is true and returns another value if the condition is false. This operator is also called a Ternary Operator.
Meta Canonicalnull
Boilerpipe Text
Decision Making in C++ In this lesson, we will understand what is Conditional Operator, and how to use it in C++ programming. Conditional Operator Conditional Operator in C++ return one value if the condition is true and returns another value if the condition is false. This operator is also called a Ternary Operator . Conditional Operator Syntax (condition) ? true_value : false_value; In the above syntax, we will write our condition in place of the condition if the condition is true then the true value will execute and if the condition is false then the false value will execute. Now let's see an example for more understanding. Example C++ program to find the greatest number among two integer variable's value using the conditional operator. #include <iostream> #include <conio.h> using namespace std; int main() { int a=10,b=5,c; c=(a>b) ? a : b; cout<<"Greatest number is "<<c; return 0; } Output Greatest number is 10 Here you can see that the condition (a>b) is true so, the statement that is written just after the ? marks will execute and the value of a gets stored in c . Nested Conditional Operator Nested Conditional Operators are possible by including conditional expression as a second (after ? ) or third part (after : ) of the ternary operator. Nested Conditional Operator Syntax (condition) ? ((condition) ? true_value : false_value) : false_value; (condition) ? true_value : ((condition) ? true_value : false_value); In the above two syntaxes, on line number 1 you can clearly see that if the first condition is true then we are checking another condition just after the ? mark of the first condition. In the same way on line number 2 if the first condition is true then the true value will execute and if it is false then we are checking another condition just after the : mark of the first condition. Now let's see an example for more understanding. Example C++ program to find the greatest number among 3 integer variable's value using the nested conditional operator. #include <iostream> #include <conio.h> using namespace std; int main() { int a=10,b=50,c=26,g; c=(a>b && a>c) ? a : ((b>a && b>c) ? b : c); cout<<"Greatest number is "<<c; return 0; } Output Greatest number is 50 Here you can see that the condition (a>b && a>c) is false so, we are checking another condition (b>a && b>c) that is written just after the : marks of the first condition and this time the condition is true so the value of b gets stored in c .
Markdown
[![Dremendo](https://www.dremendo.com/images/logo.svg)](https://www.dremendo.com/) ###### ![Dremendo Tag Line](https://www.dremendo.com/images/tagline.svg) - [C](https://www.dremendo.com/c-programming-tutorial/ "Learn C") - [C++](https://www.dremendo.com/cpp-programming-tutorial/ "Learn C++") - [Java](https://www.dremendo.com/java-programming-tutorial/ "Learn Java") - [Python](https://www.dremendo.com/python-programming-tutorial/ "Learn Python") - [HTML](https://www.dremendo.com/html-tutorial/ "Learn HTML") - [CSS](https://www.dremendo.com/css-tutorial/ "Learn CSS") - More - [C Tutorial](https://www.dremendo.com/c-programming-tutorial/ "C Programming Tutorial") - [C++ Tutorial](https://www.dremendo.com/cpp-programming-tutorial/ "C++ Programming Tutorial") - [Java Tutorial](https://www.dremendo.com/java-programming-tutorial/ "Java Programming Tutorial") - [Python Tutorial](https://www.dremendo.com/python-programming-tutorial/ "Python Programming Tutorial") - [HTML Tutorial](https://www.dremendo.com/html-tutorial/ "HTML Tutorial") - [CSS Tutorial](https://www.dremendo.com/css-tutorial/ "CSS Tutorial") [C++ Programming Tutorial](https://www.dremendo.com/cpp-programming-tutorial/ "C++ Programming Tutorial") - C++ Basic Concepts - [C++ Introduction](https://www.dremendo.com/cpp-programming-tutorial/ "C++ Introduction") - [C++ Variable](https://www.dremendo.com/cpp-programming-tutorial/cpp-variable "C++ Variable") - [C++ Data Types and Modifiers](https://www.dremendo.com/cpp-programming-tutorial/cpp-data-types-and-modifiers "C++ Data Types and Modifiers") - [C++ Naming Conventions](https://www.dremendo.com/cpp-programming-tutorial/cpp-naming-conventions "C++ Naming Conventions") - [C++ Integer Variable](https://www.dremendo.com/cpp-programming-tutorial/cpp-integer-variable "C++ Integer Variable") - [C++ Float and Double Variables](https://www.dremendo.com/cpp-programming-tutorial/cpp-float-and-double-variables "C++ Float and Double type Variable") - [C++ Character Variable](https://www.dremendo.com/cpp-programming-tutorial/cpp-character-variable "C++ Character Variable") - [C++ Boolean Variable](https://www.dremendo.com/cpp-programming-tutorial/cpp-boolean-variable "C++ Boolean Variable") - [C++ Constant Variable](https://www.dremendo.com/cpp-programming-tutorial/cpp-constant-variable "C++ Constant Variable") - [C++ Typecasting](https://www.dremendo.com/cpp-programming-tutorial/cpp-typecasting "C++ Typecasting") - Operators in C++ - [C++ Operators](https://www.dremendo.com/cpp-programming-tutorial/cpp-operators "C++ Operators") - [C++ Assignment Operators](https://www.dremendo.com/cpp-programming-tutorial/cpp-assignment-operators "C++ Assignment Operators") - [C++ Arithmetic Operators](https://www.dremendo.com/cpp-programming-tutorial/cpp-arithmetic-operators "C++ Arithmetic Operators") - [C++ Relational Operators](https://www.dremendo.com/cpp-programming-tutorial/cpp-relational-operators "C++ Relational Operators") - [C++ Logical Operators](https://www.dremendo.com/cpp-programming-tutorial/cpp-logical-operators "C++ Logical Operators") - [C++ Operator Precedence](https://www.dremendo.com/cpp-programming-tutorial/cpp-operator-precedence "C++ Operators Precedence") - Input and Output in C++ - [C++ Environment Setup](https://www.dremendo.com/cpp-programming-tutorial/cpp-environment-setup "C++ Environment Setup") - [C++ Program Basic Structure](https://www.dremendo.com/cpp-programming-tutorial/cpp-program-basic-structure "C++ Program Basic Structure") - [C++ cout Statement](https://www.dremendo.com/cpp-programming-tutorial/cpp-cout-statement "C++ cout Statement") - [C++ cin Statement](https://www.dremendo.com/cpp-programming-tutorial/cpp-cin-statement "C++ cin Statement") - [C++ Comments](https://www.dremendo.com/cpp-programming-tutorial/cpp-comments "C++ Comments") - Decision Making in C++ - [C++ Decision Making](https://www.dremendo.com/cpp-programming-tutorial/cpp-decision-making "C++ Decision Making") - [C++ if Statement](https://www.dremendo.com/cpp-programming-tutorial/cpp-if-statement "C++ if Statement") - [C++ if else Statement](https://www.dremendo.com/cpp-programming-tutorial/cpp-if-else-statement "C++ if else Statement") - [C++ if else if Statement](https://www.dremendo.com/cpp-programming-tutorial/cpp-if-else-if-statement "C++ if else if Statement") - [C++ Conditional Operator](https://www.dremendo.com/cpp-programming-tutorial/cpp-conditional-operator "C++ Conditional Operator") - [C++ switch case Statement](https://www.dremendo.com/cpp-programming-tutorial/cpp-switch-case-statement "C++ switch case Statement") - Mathematical Functions in C++ - [C++ Mathematical Functions](https://www.dremendo.com/cpp-programming-tutorial/cpp-mathematical-functions "C++ Mathematical Functions") - Loops in C++ - [C++ Loops](https://www.dremendo.com/cpp-programming-tutorial/cpp-loops "C++ Loops") - [C++ for Loop](https://www.dremendo.com/cpp-programming-tutorial/cpp-for-loop "C++ for Loop") - [C++ while Loop](https://www.dremendo.com/cpp-programming-tutorial/cpp-while-loop "C++ while Loop") - [C++ do while Loop](https://www.dremendo.com/cpp-programming-tutorial/cpp-do-while-loop "C++ do while Loop") - [C++ break and continue](https://www.dremendo.com/cpp-programming-tutorial/cpp-break-and-continue-statement "C++ break and continue Statement") - Arrays in C++ - [C++ One Dimensional Array](https://www.dremendo.com/cpp-programming-tutorial/cpp-one-dimensional-array "C++ One Dimensional Array") - [C++ Two Dimensional Array](https://www.dremendo.com/cpp-programming-tutorial/cpp-two-dimensional-array "C++ One Dimensional Array") - String in C++ - [C++ String](https://www.dremendo.com/cpp-programming-tutorial/cpp-string "C++ String") - [C++ String Methods](https://www.dremendo.com/cpp-programming-tutorial/cpp-string-methods "C++ String Methods") - Sorting in C++ - [C++ Bubble Sort](https://www.dremendo.com/cpp-programming-tutorial/cpp-bubble-sort "C++ Bubble Sort") - [C++ Selection Sort](https://www.dremendo.com/cpp-programming-tutorial/cpp-selection-sort "C++ Selection Sort") - [C++ Insertion Sort](https://www.dremendo.com/cpp-programming-tutorial/cpp-insertion-sort "C++ Insertion Sort") - Searching in C++ - [C++ Linear Search](https://www.dremendo.com/cpp-programming-tutorial/cpp-linear-search "C++ Linear Search") - [C++ Binary Search](https://www.dremendo.com/cpp-programming-tutorial/cpp-binary-search "C++ Binary Search") - Pointer and Structure in C++ - [C++ Pointer](https://www.dremendo.com/cpp-programming-tutorial/cpp-pointer "C++ Pointer") - [C++ Dynamic Memory Allocation](https://www.dremendo.com/cpp-programming-tutorial/cpp-dynamic-memory-allocation "C++ Dynamic Memory Allocation") - [C++ Structure](https://www.dremendo.com/cpp-programming-tutorial/cpp-structure "C++ Structure") - [C++ References](https://www.dremendo.com/cpp-programming-tutorial/cpp-references "C++ References") - Function in C++ - [C++ Function](https://www.dremendo.com/cpp-programming-tutorial/cpp-function "C++ Function") - [C++ Recursive Function](https://www.dremendo.com/cpp-programming-tutorial/cpp-recursive-function "C++ Recursive Function") - [C++ Function Overloading](https://www.dremendo.com/cpp-programming-tutorial/cpp-function-overloading "C++ Function Overloading") - Data Structures in C++ - [C++ Stack](https://www.dremendo.com/cpp-programming-tutorial/cpp-stack "C++ Stack") - [C++ Queue](https://www.dremendo.com/cpp-programming-tutorial/cpp-queue "C++ Queue") - [C++ Circular Queue](https://www.dremendo.com/cpp-programming-tutorial/cpp-circular-queue "C++ Circular Queue") - [C++ Double Ended Queue](https://www.dremendo.com/cpp-programming-tutorial/cpp-double-ended-queue "C++ Double Ended Queue") - [C++ Singly Linked List](https://www.dremendo.com/cpp-programming-tutorial/cpp-singly-linked-list "C++ Singly Linked List") - [C++ Doubly Linked List](https://www.dremendo.com/cpp-programming-tutorial/cpp-doubly-linked-list "C++ Doubly Linked List") - [C++ Stack using Linked List](https://www.dremendo.com/cpp-programming-tutorial/cpp-stack-using-linked-list "C++ Stack using Linked List") - [C++ Queue using Linked List](https://www.dremendo.com/cpp-programming-tutorial/cpp-queue-using-linked-list "C++ Queue using Linked List") - OOPs in C++ - [C++ Classes and Objects](https://www.dremendo.com/cpp-programming-tutorial/cpp-classes-and-objects "C++ Classes and Objects") - [C++ Instance Variables](https://www.dremendo.com/cpp-programming-tutorial/cpp-instance-variables "C++ Instance Variables") - [C++ Static Variables](https://www.dremendo.com/cpp-programming-tutorial/cpp-static-variables "C++ Static Variables") - [C++ Instance Methods](https://www.dremendo.com/cpp-programming-tutorial/cpp-instance-methods "C++ Instance Methods") - [C++ Static Methods](https://www.dremendo.com/cpp-programming-tutorial/cpp-static-methods "C++ Static Methods") - [C++ Destructor](https://www.dremendo.com/cpp-programming-tutorial/cpp-destructor "C++ Destructor") - [C++ Friend Function](https://www.dremendo.com/cpp-programming-tutorial/cpp-friend-function "C++ Friend Function") - [C++ Friend Class](https://www.dremendo.com/cpp-programming-tutorial/cpp-friend-class "C++ Friend Class") - [C++ Inheritance](https://www.dremendo.com/cpp-programming-tutorial/cpp-inheritance "C++ Inheritance") - [C++ Access Specifiers](https://www.dremendo.com/cpp-programming-tutorial/cpp-access-specifiers "C++ Access Specifiers") - [C++ Types of Inheritance](https://www.dremendo.com/cpp-programming-tutorial/cpp-types-of-inheritance "C++ Types of Inheritance") - [C++ Polymorphism](https://www.dremendo.com/cpp-programming-tutorial/cpp-polymorphism "C++ Polymorphism") - [C++ Abstract Class](https://www.dremendo.com/cpp-programming-tutorial/cpp-abstract-class "C++ Abstract Class") - File Handling in C++ - [C++ Text File Handling](https://www.dremendo.com/cpp-programming-tutorial/cpp-text-file-handling "C++ Text File Handling") - [C++ Binary File Handling](https://www.dremendo.com/cpp-programming-tutorial/cpp-binary-file-handling "C++ Binary File Handling") # Conditional Operator in C++ Programming ###### Decision Making in C++ In this lesson, we will understand what is Conditional Operator, and how to use it in C++ programming. ## Conditional Operator Conditional Operator in C++ return one value if the condition is true and returns another value if the condition is false. This operator is also called a **Ternary Operator**. ![video-poster](https://www.dremendo.com/cpp-programming-tutorial/images/cpp-tutorial.jpg) ### Conditional Operator Syntax ``` (condition) ? true_value : false_value; ``` In the above syntax, we will write our **condition** in place of the condition if the **condition** is true then the true value will execute and if the **condition** is false then the false value will execute. Now let's see an example for more understanding. #### Example C++ program to find the greatest number among two integer variable's value using the conditional operator. ``` #include <iostream> #include <conio.h> using namespace std; int main() { int a=10,b=5,c; c=(a>b) ? a : b; cout<<"Greatest number is "<<c; return 0; } ``` #### Output ``` Greatest number is 10 ``` Here you can see that the condition **(a\>b)** is true so, the statement that is written just after the **?** marks will execute and the value of **a** gets stored in **c**. ## Nested Conditional Operator Nested Conditional Operators are possible by including conditional expression as a second (after **?**) or third part (after **:**) of the ternary operator. ### Nested Conditional Operator Syntax ``` (condition) ? ((condition) ? true_value : false_value) : false_value; (condition) ? true_value : ((condition) ? true_value : false_value); ``` In the above two syntaxes, on line number 1 you can clearly see that if the first condition is true then we are checking another condition just after the **?** mark of the first condition. In the same way on line number 2 if the first condition is true then the true value will execute and if it is false then we are checking another condition just after the **:** mark of the first condition. Now let's see an example for more understanding. #### Example C++ program to find the greatest number among 3 integer variable's value using the nested conditional operator. ``` #include <iostream> #include <conio.h> using namespace std; int main() { int a=10,b=50,c=26,g; c=(a>b && a>c) ? a : ((b>a && b>c) ? b : c); cout<<"Greatest number is "<<c; return 0; } ``` #### Output ``` Greatest number is 50 ``` Here you can see that the condition **(a\>b && a\>c)** is false so, we are checking another condition **(b\>a && b\>c)** that is written just after the **:** marks of the first condition and this time the condition is true so the value of **b** gets stored in **c**. [Previous](https://www.dremendo.com/cpp-programming-tutorial/cpp-conditional-operator) [Next](https://www.dremendo.com/cpp-programming-tutorial/cpp-conditional-operator) [![Dremendo](https://www.dremendo.com/images/logo-white.svg)](https://www.dremendo.com/cpp-programming-tutorial/cpp-conditional-operator) For over a decade, Dremendo has been recognized for providing quality education. We proudly introduce our newly open online learning platform, which offers free access to popular computer courses. ##### Our Courses - [C Tutorial](https://www.dremendo.com/c-programming-tutorial/ "C Tutorial") - [C++ Tutorial](https://www.dremendo.com/cpp-programming-tutorial/ "C++ Tutorial") - [Java Tutorial](https://www.dremendo.com/java-programming-tutorial/ "Java Tutorial") - [Python Tutorial](https://www.dremendo.com/python-programming-tutorial/ "Python Tutorial") - [HTML Tutorial](https://www.dremendo.com/html-tutorial/ "HTML Tutorial") - [CSS Tutorial](https://www.dremendo.com/css-tutorial/ "CSS Tutorial") ##### News Updates © 2026 Dremendo. All Rights Reserved. - [Pricing](https://www.dremendo.com/pricing "Pricing") - [Refund and Cancellation](https://www.dremendo.com/refund-and-cancel "Refund and Cancellation") - [About Us](https://www.dremendo.com/about "About Us") - [Contact](https://www.dremendo.com/contact "Contact") - [Privacy Policy](https://www.dremendo.com/privacy-policy "Privacy Policy") - [Terms](https://www.dremendo.com/terms-of-service "Terms of Service") **Do you like cookies?** 🍪 We use cookies to ensure you get the best experience on our website. [Learn more](https://cookiesandyou.com/) I agree
Readable Markdown
###### Decision Making in C++ In this lesson, we will understand what is Conditional Operator, and how to use it in C++ programming. ## Conditional Operator Conditional Operator in C++ return one value if the condition is true and returns another value if the condition is false. This operator is also called a **Ternary Operator**. ![video-poster](https://www.dremendo.com/cpp-programming-tutorial/images/cpp-tutorial.jpg) ### Conditional Operator Syntax ``` (condition) ? true_value : false_value; ``` In the above syntax, we will write our **condition** in place of the condition if the **condition** is true then the true value will execute and if the **condition** is false then the false value will execute. Now let's see an example for more understanding. #### Example C++ program to find the greatest number among two integer variable's value using the conditional operator. ``` #include <iostream> #include <conio.h> using namespace std; int main() { int a=10,b=5,c; c=(a>b) ? a : b; cout<<"Greatest number is "<<c; return 0; } ``` #### Output ``` Greatest number is 10 ``` Here you can see that the condition **(a\>b)** is true so, the statement that is written just after the **?** marks will execute and the value of **a** gets stored in **c**. ## Nested Conditional Operator Nested Conditional Operators are possible by including conditional expression as a second (after **?**) or third part (after **:**) of the ternary operator. ### Nested Conditional Operator Syntax ``` (condition) ? ((condition) ? true_value : false_value) : false_value; (condition) ? true_value : ((condition) ? true_value : false_value); ``` In the above two syntaxes, on line number 1 you can clearly see that if the first condition is true then we are checking another condition just after the **?** mark of the first condition. In the same way on line number 2 if the first condition is true then the true value will execute and if it is false then we are checking another condition just after the **:** mark of the first condition. Now let's see an example for more understanding. #### Example C++ program to find the greatest number among 3 integer variable's value using the nested conditional operator. ``` #include <iostream> #include <conio.h> using namespace std; int main() { int a=10,b=50,c=26,g; c=(a>b && a>c) ? a : ((b>a && b>c) ? b : c); cout<<"Greatest number is "<<c; return 0; } ``` #### Output ``` Greatest number is 50 ``` Here you can see that the condition **(a\>b && a\>c)** is false so, we are checking another condition **(b\>a && b\>c)** that is written just after the **:** marks of the first condition and this time the condition is true so the value of **b** gets stored in **c**.
Shard34 (laksa)
Root Hash5957959446806291634
Unparsed URLcom,dremendo!www,/cpp-programming-tutorial/cpp-conditional-operator s443