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