If , else , else if .

Valentsea
Total
0
Shares

Salom dasturchi bugun siz bilan dasturlashda if else va else if dan foydalanishni ko’rib chiqamiz . Bugun siz u nima , nimaga kerak , qanday vaziyatlarda kerak bo’lishi haqida bilib olasiz va bularni ko’d orqali ko’rib chiqamiz .

C ++ da if – tarjimasi agar . Agar nimadir qilish kerak bo’lganda ishlatamiz . Buni ko’d orqali ko’rib chiqamiz .

#include iostream 
using name space std ;
int main() {
int M , N ;
cin >> M >> N ;
if ( M > N ) {
cout << M ; 

}
return 0 ;
Enter fullscreen mode

Exit fullscreen mode

// Bu yerda biz kiritgan ikta sonni kattasini aniqlab chiqarish dasturi tuzilgan .

Biz if ni o'zini emas else bilan yoki else if bilan ishlatishimiz mumkin .
Aslida else - tarjimasi aks holda buni ko'd orqali ko'rishingiz mumkin .

#include iostream 
using name space std ;
int main() {
int M , N ;
cin >> M >> N ;
if ( M > N ) {
cout << M ; 
else cout << N ;
Enter fullscreen mode

Exit fullscreen mode

// Bundan oldingi ko'dda faqat birinchisi katta mi yo'qmi tekshiradi . Bunda esa qaysi biri katta bo'lsa o'shani chiqaradi .

if else shart berayotganda juda ham ko'p kerak bo'ladi . Masalan shu shu ish bo'lganda shu ishni bajar unday bo'lmasa buni chiqar kabi narsalarda ishlatishimiz mumkin bo'ladi .

Bugun if else haqida ko'p narsalarni bilib oldingiz degan umiddaman . Keyingi maqolalarimizgacha ko'rishguncha dasturchi .

Total
0
Shares
Valentsea

BreathOfLife: How a Serverless App Built on AWS Helped Meet Critical Covid-19 Needs

The Covid-19 pandemic changed our lives in many ways and one of the most significant impacts has been…

You May Also Like