Lesson 5 of 24

Loops: for, while, range-forLoops: for, while and range-for

9 min 25 XP

for, while, do-while C போலவே. C++11-ல் range-based for: for (int x : list) ஒவ்வொரு உறுப்பையும் தரும்.

for, while and do-while work like C. C++11 adds the range-based for: for (int x : list) visits every element.

Example: edit me and press Run

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.

Challenge

+25 XP

n-ஐப் படித்து முதல் n Fibonacci எண்களை space விட்டு print செய்யுங்கள் (0 1 1 2 ...). long long பயன்படுத்துங்கள். Input: 8 → Output: 0 1 1 2 3 5 8 13

Read n and print the first n Fibonacci numbers separated by spaces (0 1 1 2 ...). Use long long. Input: 8 → Output: 0 1 1 2 3 5 8 13

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.