SEBA Class 10 Computer Science Chapter 4 – Introduction to Loops Notes PDF
4.1 Introduction to Loops
Loop is one of the most important concepts in programming. A loop allows a set of statements to be executed repeatedly without writing the same code again and again.
For example, if we want to display a sentence 1000 times, writing 1000 printf() statements is not practical. Instead, we can use a loop and write the statement only once.
Loops make programs shorter, easier to understand, and more efficient.
4.2 Importance of Loop in Programming Language
Whenever a task needs to be performed repeatedly, loops provide an efficient solution.
Advantages of Loops
- Reduce program length
- Improve readability
- Avoid repeated code
- Save programming time
- Make programs easier to maintain
4.3 Types of Loops in C
C programming language provides three types of loops:
- While Loop
- Do-While Loop
- For Loop
4.4 While Loop
The while loop checks the condition before executing the statements inside the loop.
Syntax
while(condition)
{
statements;
}
The loop continues as long as the condition remains true.
Example
int i = 0;
while(i < 5)
{
printf("I read in Class X");
i++;
}
Features of While Loop
- Condition is checked first
- May execute zero times
- Useful when number of iterations is not fixed
4.5 Do-While Loop
The do-while loop executes the statements first and checks the condition later.
Syntax
do
{
statements;
}
while(condition);
This loop always executes at least once even if the condition is false.
Example
int i = 0;
do
{
printf("I read in Class X");
i++;
}
while(i < 5);
Advantages of Do-While Loop
- Executes at least once
- Suitable for menu-driven programs
- User gets a chance to perform an action before checking condition
4.6 Difference Between While and Do-While Loop
| While Loop | Do-While Loop |
|---|---|
| Condition checked first | Condition checked later |
| May execute zero times | Executes at least once |
| Entry controlled loop | Exit controlled loop |
4.7 For Loop
The for loop is commonly used when the number of iterations is known in advance.
Structure of For Loop
A for loop consists of:
- Initialization Expression
- Condition Checking Expression
- Update Expression
Syntax
for(initialization;
condition;
update)
{
statements;
}
Example
for(i=0;i<5 i="" in="" pre="" printf="" read="" x="">5>
4.8 Applications of Loops
Loops can be used for many programming tasks:
- Printing patterns
- Calculating summation
- Finding factorial
- Checking prime numbers
- Processing large amounts of data
4.9 Programs Using Loops
A. Summation of Series
Loops can be used to calculate:
1 + 2 + 3 + ... + N
At every iteration, the current number is added to the previous sum.
B. Summation of N Numbers
The user enters N numbers and the loop calculates the total sum.
C. Pattern Printing
Loops are widely used to display patterns such as:
X X X X X X X X X X X X X X X
D. Extracting Digits of a Number
Using modulus (%) and division (/), loops can extract each digit from a number.
Example:
8724 Digits: 8 7 2 4
E. Summation of Digits
Example:
Number = 8724 Sum = 8+7+2+4 Result = 21
F. Prime Number Check
Loops can test whether a number is divisible by any number other than 1 and itself.
If no divisor is found, the number is prime.
Important Keywords
| Keyword | Meaning |
|---|---|
| Loop | Repeated execution of statements |
| While Loop | Entry controlled loop |
| Do-While Loop | Exit controlled loop |
| For Loop | Loop with initialization, condition and update |
| Iteration | One execution of a loop |
| Break | Terminates loop execution |
Summary
In this chapter, we learned the importance of loops in C programming. We studied while loops, do-while loops, and for loops along with their syntax, working principles, and practical applications. We also learned how loops can be used to calculate summations, print patterns, extract digits, and check prime numbers. :contentReference[oaicite:0]{index=0}
Frequently Asked Questions (FAQ)
1. Why do we use loops in programming?
Loops help execute a set of statements repeatedly without rewriting the same code.
2. Name the three types of loops in C.
While loop, Do-While loop, and For loop.
3. Which loop executes at least once?
Do-While loop.
4. What are the three parts of a for loop?
Initialization, Condition Checking, and Update Expression.
5. What is an iteration?
One complete execution of a loop is called an iteration.
📘 Chapter 2 PDF Notes
Read the complete Chapter 4 PDF Notes directly on the website.
End of Chapter 4 – Introduction to Loops

Post a Comment