C++ da for loop

C++ da for loop


C++ dasturlash tilida for tsikli kodni takrorlash uchun ishlatiladi. Bu tsikl ma’lum bir shart bajarilguncha kod blokini bir necha marta bajaradi. For tsikli odatda takrorlanishlar soni oldindan ma’lum bo’lganda ishlatiladi.
Misol tariqasida:
#include
using namespace std;

int main() 
{
   // 1 dan 10 gacha bo'lgan sonlarni chiqarish
   for (int i = 1; i <= 10; i++) 
{
    cout << i << " ";
}
    return 0;
}

natija ==> 1 2 3 4 5 6 7 8 9 10

Qisqacha izoh:

Boshlang’ich holat ==> int i = 1 (i o’zgaruvchisi 1 ga teng bo’lsin.)
Shart ==> i <= 10 (i 10 dan katta bo’lguncha davom etsin.)
Yangilanish ==> i++ (shart true bo’lganda i 1 ga oshsin.)

AZIZOV AHMADJON



Source link
lol

By stp2y

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.