Conditional operator

Conditional operator – shart operatori(ternary operator).

Syntax of of ternary:
Condition ? A : B;

Masalan:

#include <iostream>

using namespace std;

int main()
{

int a = 7,b = 77;

cout << (a > b ? 1 : 0) << endl; /…


This content originally appeared on DEV Community and was authored by Sanjar Rashidov

Conditional operator - shart operatori(ternary operator).

Syntax of of ternary:
Condition ? A : B;

Masalan:

#include <iostream>

using namespace std;

int main()
{

    int a = 7,b = 77;

    cout << (a > b ? 1 : 0) << endl; //0
    cout << (a < b ? 1 : 0) << endl; //1

    return 0;
}


This content originally appeared on DEV Community and was authored by Sanjar Rashidov


Print Share Comment Cite Upload Translate Updates
APA

Sanjar Rashidov | Sciencx (2024-11-02T09:55:05+00:00) Conditional operator. Retrieved from https://www.scien.cx/2024/11/02/conditional-operator/

MLA
" » Conditional operator." Sanjar Rashidov | Sciencx - Saturday November 2, 2024, https://www.scien.cx/2024/11/02/conditional-operator/
HARVARD
Sanjar Rashidov | Sciencx Saturday November 2, 2024 » Conditional operator., viewed ,<https://www.scien.cx/2024/11/02/conditional-operator/>
VANCOUVER
Sanjar Rashidov | Sciencx - » Conditional operator. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/11/02/conditional-operator/
CHICAGO
" » Conditional operator." Sanjar Rashidov | Sciencx - Accessed . https://www.scien.cx/2024/11/02/conditional-operator/
IEEE
" » Conditional operator." Sanjar Rashidov | Sciencx [Online]. Available: https://www.scien.cx/2024/11/02/conditional-operator/. [Accessed: ]
rf:citation
» Conditional operator | Sanjar Rashidov | Sciencx | https://www.scien.cx/2024/11/02/conditional-operator/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.