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.