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.