Skip to content
Programs · Program 6-10

Q.Program 6-10: Program to print first 5 natural numbers using while loop.

Sikkim CbseNCERTSubjective· 2mImportance★★★★★est
36% · 14/39 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Initialise a counter to 1, loop while count <= 5: printing and incrementing it — the loop prints 1 2 3 4 5 and stops when the counter reaches 6.

The idea. A while loop is condition-controlled: it keeps repeating as long as a Boolean expression stays True. To count with it you must manage the counter yourself — initialise it before the loop, test it in the condition, and update it inside the body. (A for loop does all three for you; this program shows the manual version.)

# Program 6-10: print the first 5 natural numbers using a while loop
count = 1
while count <= 5:
    print(count)
    count += 1

Expected output

1
2
3
4
5

Dry run

Passcount at testcount <= 5Printedcount after += 1
11True12
22True23
33True34
44True45
55True56

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.