C++ da for loop
Ahmadjon
Posted on November 19, 2024
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
💖 💪 🙅 🚩
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
githubcopilot AI Innovations at Microsoft Ignite 2024 What You Need to Know (Part 2)
November 29, 2024