C++ da for loop

ahmadjon_ce07fbecb974f925

Ahmadjon

Posted on November 19, 2024

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;
}
Enter fullscreen mode Exit fullscreen mode

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

💖 💪 🙅 🚩
ahmadjon_ce07fbecb974f925
Ahmadjon

Posted on November 19, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related