Conditional operator

Conditional operator – ingliz tilidan tarjima qilinganda shart operatori degan ma’noni anglatadi.
Uning qisqacha syntaxi quyidagicha:
Condition ? A : B;
Kodga o’tadigan bo’lsak:

#include <iostream>

using namespace std;

int main()
{

in…


This content originally appeared on DEV Community and was authored by Munisa Kuranbekova

Conditional operator - ingliz tilidan tarjima qilinganda shart operatori degan ma'noni anglatadi.
Uning qisqacha syntaxi quyidagicha:
Condition ? A : B;
Kodga o'tadigan bo'lsak:

#include <iostream>

using namespace std;

int main()
{  

    int son;
    cin >> son;

int result = son > 0? 1 : 0;

cout << result << endl;


    return 0;
}

kodni tahlil qiladigan bo'lsak son 0 dan kattami yoki yo'qmi shuni tekshiradi va resultga saqlaydi. Son o'zgaruvchisiga kiritgan sonimiz 0 dan katta bo'lsa 1 ni yo'qsa nolni chop etadi.


This content originally appeared on DEV Community and was authored by Munisa Kuranbekova


Print Share Comment Cite Upload Translate Updates
APA

Munisa Kuranbekova | Sciencx (2024-11-02T13:07:02+00:00) Conditional operator. Retrieved from https://www.scien.cx/2024/11/02/conditional-operator-2/

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

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.