Introduction to Loops | Chapter 4 |  Class 10 Computer Science 571(NCERT) Question and Answer | Class 10 Computer Science 571(NCERT) Question and Answer Solutions English Medium |


Introduction to Loops

Chapter 4


Questions:

1. Why do we use a loop in a C Program ?

āφāĻŽি āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽ āĻāϟাāϤ āϞুāĻĒ āĻ•িāϝ় āĻŦ্āĻ¯ā§ąāĻšাā§° āϕ⧰োঁ?

Ans: In C programming, there are three loops: for loops, loop vial loop and vial. Loops in C can also be combined with other control statements such as brake statements, goto statements, and control statements.

(āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽিংāϤ, āϤিāύিāϟা āϞুāĻĒ āφāĻ›ে: āϞুāĻĒ, āϞুāĻĒ āĻ­াāχāϞ āϞুāĻĒ āφ⧰ু āĻ­াāχāϞ⧰ āĻŦাāĻŦে। āϚি-āϤ āϞুāĻĒāĻŦোā§° āĻ…āύ্āϝাāύ্āϝ āύিāϝ়āύ্āϤ্ā§°āĻŖ āĻŦিāĻŦৃāϤি āϝেāύে āĻŦ্ā§°েāĻ• āώ্āϟেāϟāĻŽেāĻŖ্āϟ, āĻ—োāϟো āώ্āϟেāϟāĻŽেāĻŖ্āϟ, āφ⧰ু āύিāϝ়āύ্āϤ্ā§°āĻŖ āĻŦিāĻŦৃāϤিā§° āϏৈāϤেāĻ“ āĻāĻ•āϤ্ā§°িāϤ āϕ⧰িāĻŦ āĻĒাā§°ি।)

2. Do we need to use only one type of loop in a C program? Justify your answer by Writing a C Program.

(āφāĻŽি āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽ āĻāϟাāϤ āĻ•েā§ąāϞ āĻāĻ• āĻĒ্ā§°āĻ•াā§°ā§° āϞুāĻĒ āĻŦ্āĻ¯ā§ąāĻšাā§° āϕ⧰িāĻŦ āϞাāĻ—িāĻŦ āύেāĻ•ি? āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽ āĻāϟা āϞিāĻ–ি āφāĻĒোāύাā§° āωāϤ্āϤ⧰āϟো āύ্āϝাāϝ়āϏāĻ™্āĻ—āϤ āϕ⧰āĻ•।)

Ans:  No, we can use all types of loops in a C program.

(āύāĻšā§Ÿ, āφāĻŽি āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽ āĻāϟাāϤ āĻŦিāĻ­িāύ্āύ āϧ⧰āĻŖā§° āϞুāĻĒ āĻŦ্ā§Ÿā§ąāĻšাā§° āϕ⧰িāĻŦ āĻĒাā§°ো।)

3. What will happen if We Write a loop with 1 in place of the condition? try it in a Simple C Program. Hint:

(āϝāĻĻি āφāĻŽি āĻ…ā§ąāϏ্āĻĨাāϟোā§° āĻ াāχāϤ 1 ā§° āϏৈāϤে āĻāϟা āϞুāĻĒ āϞিāĻ–োঁ āϤেāύ্āϤে āĻ•ি āĻš'āĻŦ? āχāϝ়াāĻ• āĻāϟা āϏ⧰āϞ āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽāϤ āϚেāώ্āϟা āϕ⧰āĻ•। āχāĻ™্āĻ—িāϤ:)

while (1) (āφāύāĻšাāϤে (1))

printf ("We must raise our voice against Corruption \n");

(āĻĒ্ā§°িāĻŖ্āϟāĻĢ ("āφāĻŽি āĻĻুā§°্āύীāϤিā§° āĻŦিā§°ুāĻĻ্āϧে āĻŽাāϤ āĻŽাāϤিāĻŦ āϞাāĻ—িāĻŦ") 

Ans: Time (1) or (no non-zero value) is used for infinite loops. There are no conditions for some time. Since 1 or any non-zero has a value, the state is always true.

(āĻ…āϏীāĻŽ āϞুāĻĒā§° āĻŦাāĻŦে āϏāĻŽāϝ় (1) āĻŦা (āĻ•োāύো āĻ…-āĻļূāύ্āϝ āĻŽাāύ) āĻŦ্āĻ¯ā§ąāĻšাā§° āϕ⧰া āĻšāϝ়। āĻ•িāĻ›ু āϏāĻŽāϝ়ā§° āĻŦাāĻŦে āĻ•োāύো āϚ⧰্āϤ āύাāχ। āϝিāĻšেāϤু 1 āĻŦা āϝিāĻ•োāύো āĻ…-āĻļূāύ্āϝ⧰ āĻŽূāϞ্āϝ āφāĻ›ে, ā§°াāϜ্āϝāϏāĻĻাāϝ়ে āϏঁāϚা।)

4. Name different portions of for a loop. Can we put more than one statement within a portion?

(āĻāϟা āϞুāĻĒā§° āĻŦাāĻŦে ā§° āĻŦিāĻ­িāύ্āύ āĻ…ংāĻļā§° āύাāĻŽ āϞিāĻ–া। āφāĻŽি āĻāϟা āĻ…ংāĻļā§° āĻ­িāϤ⧰āϤ āĻāϟাāϤāĻ•ৈ āĻ…āϧিāĻ• āĻŦāĻ•্āϤāĻŦ্āϝ ā§°াāĻ–িāĻŦ āĻĒাā§°োāύে?)

Ans: There are two parts to one for the loop: a head that specifies repetition, and a body that is performed once per repetition. The header often declares a clear loop counter or loop variable, which allows the body to know which one is being iterated.

(āϞুāĻĒā§° āĻŦাāĻŦে āĻāϟাā§° āĻĻুāϟা āĻ…ংāĻļ āφāĻ›ে: āĻĒুāύ⧰াāĻŦৃāϤ্āϤি āύিā§°্āϧাā§°āĻŖ āϕ⧰া āĻŽুā§°, āφ⧰ু āĻĒ্ā§°āϤিāϟো āĻĒুāύ⧰াāĻŦৃāϤ্āϤিāϤ āĻāĻŦাā§° āĻ•ৈ āϕ⧰া āĻļā§°ীā§°। āĻšেāĻĄাā§°āϟোā§ąে āĻĒ্ā§°াāϝ়ে āĻāϟা āϏ্āĻĒāώ্āϟ āϞুāĻĒ āĻ•াāωāĻŖ্āϟাā§° āĻŦা āϞুāĻĒ āĻ­েā§°িāϝ়েāĻŦāϞ āϘোāώāĻŖা āϕ⧰ে, āϝি āĻļā§°ীā§°āĻ• āĻ•োāύāϟো āĻ•āϟা āĻšৈāĻ›ে āϜাāύিāĻŦāϞৈ āĻĻিāϝ়ে।)

5. Answer with TRUE of FALSE.

āĻŽিāĻ›াā§° āϏāϤ্āϝāϤাā§° āϏৈāϤে āωāϤ্āϤ⧰ āĻĻিāϝ়āĻ•।

(i) If the condition of the while loop is false, the control comes to the second statement inside the loop.

(āϝāĻĻি āϞুāĻĒ āϏāĻŽāϝ়āϤ āĻ…ā§ąāϏ্āĻĨা āĻŽিāĻ›া āĻšāϝ়, āύিāϝ়āύ্āϤ্ā§°āĻŖāϟো āϞুāĻĒā§° āĻ­িāϤ⧰āϤ āĻĨāĻ•া āĻĻ্āĻŦিāϤীāϝ় āĻŦিāĻŦৃāϤিāϞৈ āφāĻšে।)

Ans: If the condition is false,

This means that the code should always be implemented first and then the expression or test status will be assessed. If this is true, the body of the code loop works again. ... If the expression is false, the loop is eliminated and controls the transition to the statement after the do-well loop.

(āϝāĻĻি āϚ⧰্āϤāϟো āĻŽিāĻ›া āĻšāϝ়,

āχāϝ়াā§° āĻ…ā§°্āĻĨ āĻšৈāĻ›ে āϝে āĻ•োāĻĄāϟো āϏāĻĻাāϝ়ে āĻĒ্ā§°āĻĨāĻŽে āĻ•াā§°্āϝāϕ⧰ী āϕ⧰িāĻŦ āϞাāĻ—ে āφ⧰ু āϤাā§° āĻĒিāĻ›āϤ āĻ…āĻ­িāĻŦ্āϝāĻ•্āϤি āĻŦা āĻĒā§°ীāĻ•্āώাā§° āϏ্āĻĨিāϤি āĻŽূāϞ্āϝাāϝ়āύ āϕ⧰া āĻš'āĻŦ। āϝāĻĻি āĻāχāϟো āϏঁāϚা āĻšāϝ়, āĻ•োāĻĄ āϞুāĻĒā§° āĻļā§°ীā§°ে āĻĒুāύ⧰ āĻ•াāĻŽ āϕ⧰ে। ... āϝāĻĻি āĻ…āĻ­িāĻŦ্āϝāĻ•্āϤিāϟো āĻŽিāĻ›া āĻšāϝ়, āϞুāĻĒāϟো āφঁāϤ⧰ āϕ⧰া āĻšāϝ় āφ⧰ু āĻĄু-ā§ąেāϞ āϞুāĻĒā§° āĻĒিāĻ›āϤ āĻŦিāĻŦৃāϤিāϞৈ āĻĒā§°িā§ąā§°্āϤāύ āύিāϝ়āύ্āϤ্ā§°āĻŖ āϕ⧰ে।)

(ii) We can use at most three loops in a single C program.

(āφāĻŽি āĻāϟা āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽāϤ āϏ⧰্āĻŦাāϧিāĻ• āϤিāύিāϟা āϞুāĻĒ āĻŦ্āĻ¯ā§ąāĻšাā§° āϕ⧰িāĻŦ āĻĒাā§°োঁ।)

Ans: False. We can use more than three loops in a C program

(āĻŽিāĻ›া, āφāĻŽি āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽāϤ āϤিāύিāϤāĻ•ৈ āĻŦেāĻ›ি āϞুāĻĒ āĻŦ্ā§Ÿā§ąāĻšাā§° āϕ⧰িāĻŦ āĻĒাā§°ো। 

(iii) The statements inside the do-while loop executes at least once even if the condition is false.

(āĻ…ā§ąāϏ্āĻĨাāϟো āĻŽিāĻ›া āĻš'āϞেāĻ“ āĻĄু-ā§ąেāϞ āϞুāĻĒā§° āĻ­িāϤ⧰āϤ āĻĨāĻ•া āĻŦিāĻŦৃāϤিāĻŦোā§° āĻ•āĻŽেāĻ“ āĻāĻŦাā§° āĻ•াā§°্āϝāϕ⧰ী āĻšāϝ়।)

Ans: The loop in the do-well loop is actually applied first then the situation is examined so that whether the result is applied in the first iteration is true or false, so we have concluded that the do-well loop is effective at least once despite the situation being incorrect.

(āĻĄু-ā§ąেāϞ āϞুāĻĒā§° āϞুāĻĒāϟো āĻĒ্ā§°āĻ•ৃāϤāϤে āĻĒ্ā§°āĻĨāĻŽে āĻĒ্ā§°āϝ়োāĻ— āϕ⧰া āĻšāϝ় āϤাā§° āĻĒিāĻ›āϤ āĻĒā§°িāϏ্āĻĨিāϤিāϟো āĻĒā§°ীāĻ•্āώা āϕ⧰া āĻšāϝ় āϝাāϤে āĻĒ্ā§°āĻĨāĻŽ āĻĒুāύ⧰াāĻŦৃāϤ্āϤিāϤ āĻĢāϞাāĻĢāϞāĻĒ্ā§°āϝ়োāĻ— āϕ⧰া āĻšāϝ় āύে āĻŽিāĻ›া āĻšāϝ়, āϏেāϝ়েāĻšে āφāĻŽি āĻāχ āϏিāĻĻ্āϧাāύ্āϤāϤ āωāĻĒāύীāϤ āĻšৈāĻ›ো āϝে āĻĒā§°িāϏ্āĻĨিāϤিāϟো āĻ­ুāϞ āĻšোā§ąা āϏ্āĻŦāϤ্āĻŦেāĻ“ āĻĄু-ā§ąেāϞ āϞুāĻĒ āĻ•āĻŽেāĻ“ āĻāĻŦাā§° āĻ•াā§°্āϝāϕ⧰ী āĻšāϝ়।)

(iv) Only the first statement inside the do-while loop executes when the condition is false.

(āĻ…ā§ąāϏ্āĻĨাāϟো āĻŽিāĻ›া āĻš'āϞে āĻ•েā§ąāϞ āĻĄু-ā§ąেāϞ āϞুāĻĒā§° āĻ­িāϤ⧰āϤ āĻĨāĻ•া āĻĒ্ā§°āĻĨāĻŽ āĻŦিāĻŦৃāϤিāϟোā§ąেāχ āĻ•াā§°্āϝāϕ⧰ী āϕ⧰ে।)

Ans:  True. (āϏঁāϚা)

(v) In a do-while loop, the condition is written at the end of the loop. 

āĻāϟা āĻĄু-ā§ąেāϞ āϞুāĻĒāϤ, āĻ…ā§ąāϏ্āĻĨাāϟো āϞুāĻĒā§° āĻļেāώāϤ āϞিāĻ–া āĻšāϝ়।

Ans: False.(āĻŽিāĻ›া)

6. Programming exercises:


A. Write a C program to find the summation of the following series

āύিāĻŽ্āύāϞিāĻ–িāϤ āĻļৃংāĻ–āϞাā§° āϏাā§°াংāĻļ āĻŦিāϚাā§°িāĻŦāϞৈ āĻāϟা āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽ āϞিāĻ–āĻ•

(a). 12+22+32 + 42 + ... + N²

(b). 13+ 23 +33 +43 + ... + N³

(c). 12+23+ 34 + ... + N (N+1)

Ans:                              

B. Write a C program to continuously take a number as input and announce whether the number is odd or even. Hint: use do-while loop.

(āĻāϟা āύāĻŽ্āĻŦā§°āĻ• āύিā§°āύ্āϤ⧰ āχāύāĻĒুāϟ āĻšিāϚাāĻĒে āϞ'āĻŦāϞৈ āφ⧰ু āύāĻŽ্āĻŦā§°āϟো āĻ…āĻĻ্āĻ­ূāϤ āύে āϏāĻŽাāύ āϘোāώāĻŖা āϕ⧰িāĻŦāϞৈ āĻāϟা āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽ āϞিāĻ–āĻ•। āχāĻ™্āĻ—িāϤ: āĻĄু-ā§ąাāχāϞ āϞুāĻĒ āĻŦ্āĻ¯ā§ąāĻšাā§° āϕ⧰āĻ•।)

Ans:  in the while loop construct, first the condition is checked and then the statements are executed as long as the condition is true.

C. Write a C program to display the following pattern.

āϤāϞ⧰ āφ⧰্āĻšিāϟো āĻĒ্ā§°āĻĻā§°্āĻļāύ āϕ⧰িāĻŦāϞৈ āĻāϟা C āĻĒ্ā§°āĻ—্ā§°েāĻŽ āϞিāĻ–āĻ•।

1

11

111

1111

11111


D. Write a C program to display the following pattern.

āύিāĻŽ্āύāϞিāĻ–িāϤ āφ⧰্āĻšিāϟো āĻĒ্ā§°āĻĻā§°্āĻļāύ āϕ⧰িāĻŦāϞৈ āĻāϟা āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽ āϞিāĻ–āĻ•।

5

54

543

5432

54321


E. Write a C program to display the following pattern.

āύিāĻŽ্āύāϞিāĻ–িāϤ āφ⧰্āĻšিāϟো āĻĒ্ā§°āĻĻā§°্āĻļāύ āϕ⧰িāĻŦāϞৈ āĻāϟা āϚি āĻĒ্ā§°'āĻ—্ā§°াāĻŽ āϞিāĻ–āĻ•।

54321

5432

543

54

5


Type & Assamese Translate : Himashree Bora.

Author-Dikha Bora

Post ID: DABP002204