DEV Community

Muhammadyusuf
Muhammadyusuf

Posted on

1

c++ for loophaqida malumot

for loop bu whlilega va do whilega oshqashnarsadir faqat u sinteks va yozilishi boshqacha

for (initialization; condition; increment) {
Enter fullscreen mode Exit fullscreen mode

shunday boladi

#include <iostream>
using namespace std;

int main() {
    for (int i = 0; i < 10; i++) {
        cout << "i ning qiymati: " << i << endl;
    }
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

bu qanday ishlaydi?
i ning qiymati: 0
i ning qiymati: 1
i ning qiymati: 2
i ning qiymati: 3
i ning qiymati: 4
i ning qiymati: 5
i ning qiymati: 6
i ning qiymati: 7
i ning qiymati: 8
i ning qiymati: 9
Qanday ishlaydi:

int i = 0; — i o‘zgaruvchisi 0 ga teng bo‘ldi.
i < 10; — Agar i 10 dan kichik bo‘lsa, tsikl ishlaydi.
cout << "i ning qiymati: " << i << endl; — Hozirgi i qiymatini chiqaradi.
i++ — bu koddan oldin

cout << "i ning qiymati: " << i << endl;
Enter fullscreen mode Exit fullscreen mode

shu kod ishlaydi va bundan kegin

i++;
Enter fullscreen mode Exit fullscreen mode

ishlaydi
agar siz forni shunday holatda korsangi
agar initialization; condition; incrementshular yoqbolsa

for(;;)
Enter fullscreen mode Exit fullscreen mode

shunday yoziladi

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay