DEV Community

feyyame1
feyyame1

Posted on

C++ da ASSIGMENT OPERATORI haqida ma'lumot.

biz c++ da bugungi darsimiz ASSIGMENT OPERATOR ni o'rgandik.
biz int ishorasi bilan 1 ta son belgilab, uni keyinchali o'zgartirsak ham bo'ladi.
unga misol:

int a = 10;
  string ism = "rahima";

  cout << a << endl;
  cout << ism << endl;

  a = 20;
  ism = "kimsan";
  cout << a << endl;
  cout << ism;

}

Enter fullscreen mode Exit fullscreen mode

biz int bilan ishlaganda -+ ni +- ; /* ni */ ga o'zgatirsak ham bo'ladi .

int a = 5;
int b = 6;
b = b+ a; // b +=a;
a = a- 10; // a -=10;

b*=3; // b = b * 3;
a /= b; // a = a / b;
cout << b;
}

Enter fullscreen mode Exit fullscreen mode

masala uchun: biz doiraning yuzini olsak,

Doiraning uzunligi sifatida bittakasr-sonNni o'qiymiz. Shu doirani yuzini topib va natijani nuqtadan keyin 0 ta aniqlikda chop etamiz.

π ning qiymati:3.14
Raduisi r bo'lgan doiraning uzunligi: L = 2πr bizda r no'malum sonni topishimiz kerak.
Doiraning yuzi formulasi: S = πr^2
MASALANI javobi:

int main 2() {
double L;
  cin >> L;
  float PI = 3.14;
  float r = L/(2*PI);
  float S= PI * (r * r);
  cout << round(S);
return 0;

  }

Enter fullscreen mode Exit fullscreen mode

biz bugun assigment operatori haqida ilk malumotni egalladik.
bunda birinchi navbatda int a da a ni yani biron sonni oqib olishimiz zarur.

int a = 10;
  string ism = "rahima";
Enter fullscreen mode Exit fullscreen mode

va biron bir soz kiritishimiz kerak.
biz int a da yozgan sonimiz va harifimiz masalan son bo'ladigon bo'lsa, (10) buni biz osha qismda 1 marta ishlatsak bo'ladi!!!

@dawroun

Top comments (0)