Bird
0
0

How can you use a loop to sum numbers from 1 to 100 in C?

hard📝 Application Q9 of 15
C - Loops
How can you use a loop to sum numbers from 1 to 100 in C?
AUse a for loop to add each number to a total variable
BUse a while loop but forget to update the counter
CUse a loop but print numbers instead of summing
DUse recursion instead of a loop
Step-by-Step Solution
Solution:
  1. Step 1: Understand summing with loops

    Initialize a total variable to 0, then add each number from 1 to 100.
  2. Step 2: Use for loop for counting and adding

    For loop runs from 1 to 100, adding each value to total.
  3. Final Answer:

    Use a for loop to add each number to a total variable -> Option A
  4. Quick Check:

    Summing needs loop + accumulator variable [OK]
Quick Trick: Add each number inside loop to a total variable [OK]
Common Mistakes:
  • Forgetting to update counter
  • Printing instead of summing
  • Confusing recursion with loops

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes