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
Munisa Kuranbekova | Sciencx (2024-11-02T13:07:02+00:00) Conditional operator. Retrieved from 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.