DEV Community

Cover image for Operators and true folse .
Shoxjaxon2008
Shoxjaxon2008

Posted on

Operators and true folse .

Salom dasturchi bugun siz bilan operatorslardan eng qiyini hisoblangan ++ va -- operatorlari bilan tanishamiz va yana true folse nima ekanligi va qanday ishlashini ham tushuntirib o'taman .

Operators ++ va --
++ bu songa 1 qiyat qo'shadi .
-- bu sondan 1 qiymat ayiradi.
Tushuntirish
Masalan n son bor deylik . Agar ++ ishorasi n sondan oldin kelsa u birinchi hisoblanadi . ++ n kabi . Agar ++ ishorasi n sonidan keyin kelsa u barcha amallardan keyin bajariladi . n ++ kabi

                         _Tushuntirish(1)_
Enter fullscreen mode Exit fullscreen mode

Masalan a son bor deylik . Agar -- ishorasi a sondan oldin kelsa u birinchi hisoblanadi . -- a kabi . Agar -- ishorasi a sonidan keyin kelsa u barcha amallar bajarilgandan keyin bajariladi . n -- kabi .

ESLATMA
O'zgaruvchidan keyin kelgan ishoralar faqat qolib ketgan o'zgaruvchisi bilan qiymat o'zgartiradi .

Bu operatorslarni kod orqali tushunib olishingiz mumkin .

int main5() {

int a = 5 ; 
a ++ ;

cout << ++ a << endl ; // 7 
cout << a ++ << endl ; // 7 
cout << a -- << " " << a ++ << endl ;  // 8 //7
cout << ++ a << " " << a ++ << endl ;  // 9 //9
cout << a ++ << " " << ++ a << endl ;  // 10 // 12 
cout << -- a << " " << a -- << endl ;  // 11 // 11
cout << a ++ << " " << -- a ;  // 10 // 10 
// sonlari chiqadi . 
  return 0 ; 
} 
Enter fullscreen mode Exit fullscreen mode
                        _**True va Folse**_
Enter fullscreen mode Exit fullscreen mode

True va Folse - tarjimasi to'g'ri va hato
C ++ dasturlash tilida true bo'lsa ekranga 1 soni chiqadi .
Folse bo'lsa ekranga 0 soni chiqadi .

buni hozir o'zingiz ko'dda tushunib olishingiz mumkin .

// Description : Nsonini o'qing. AgarNsoni 20 va 30 orasida (20 va 30 ham kiradi) bo'lsa,1ni chop eting. Aks holda0ni chop eting.
#include <iostream> 
using namespace std ; 
int main() {

int n ; 
cin >> n ;
cout << ((n >= 20 && n <=30 )) ;

Enter fullscreen mode Exit fullscreen mode

Maqolamdan ko'p narsa bilib oldingiz degan umiddaman keyingi maqolamgacha hayr salomat bo'ling .

Top comments (0)