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.