Lesson 5 of 24

Loops: for, while మరియు range-for

9 min 25 XP

for, while, do-while C లాగే పనిచేస్తాయి. C++11 range-based for ను జోడిస్తుంది: for (int x : list) ప్రతి అంశాన్ని సందర్శిస్తుంది.

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 సంఖ్యలను spaces తో print చేయండి (0 1 1 2 ...). 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.