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.