Advertisements
Chapters
1.2: Elementary Concept of Objects and Classes
1.3: Values and Data Types
1.4: Operators in Java
1.5: Introduction to Java
1.5: Input in Java
1.6: Mathematical Library Methods
1.7: Conditional Statements in Java
▶ 1.8: Iterative Constructs in Java
1.9: Nested Loop
2: Library Classes
3: Arrays (Single Dimensional and Double Dimensional)
4: String Handling
5: User - Defined Methods
6: Class as the Basis of all Computation (Objects and Classes)
7: Constructors
8: Encapsulation and Inheritance
![Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.8 - Iterative Constructs in Java Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.8 - Iterative Constructs in Java - Shaalaa.com](/images/computer-applications-english-class-10-icse_6:1e1eb1b47d2b4696b609e5cd9260118f.jpg)
Advertisements
Solutions for Chapter 1.8: Iterative Constructs in Java
Below listed, you can find solutions for Chapter 1.8 of CISCE Avichal for Computer Applications [English] Class 10 ICSE.
Avichal solutions for Computer Applications [English] Class 10 ICSE 1.8 Iterative Constructs in Java Review Insight [Page 120]
Differentiate between a Null loop and an Infinite loop.
State one similarity between while loop and do-while loop.
What is meant by an endless loop?
Give an example of an endless loop.
Give an example to illustrate null loop.
What is a delay loop?
Find the errors in the following program snippet:
for (int k = 1; k <= 10; k--)
System.out.println(k);
Rewrite the program by using while loop:
int a, b=0, c;
System.out.println("The numbers are:");
for (a = 1; a <= 10; a++)
{
c = b * b;
System.out.print(c);
b = b + 1;
}
Convert the following while loop to the corresponding for loop:
int m = 5, n = 10;
while (n >= 1)
{
System.out.println(m*n);
n--;
}
Analyse the given program segment and answer the following questions.
for (int m = 5; m <= 20; m += 5)
{
if (m % 3 == 0)
break;
else
if (m % 5 == 0)
System.out.println (m);
continue;
}
- Write the output of the program segment.
- How many times does the body of the loop get executed?
Predict the output and also mention the number of times the loop runs.
int a = 0;
while (a > −5)
{
System.out.print(a + " ");
System.out.print((--a * 2));
System.out.println();
--a;
}
Avichal solutions for Computer Applications [English] Class 10 ICSE 1.8 Iterative Constructs in Java EXERCISES [Pages 122 - 127]
Multiple Choice Questions:
Which of the following statements will terminate the premature execution of a program?
System.exit(0)
Break
Stop
End
Which of the following for loop will not be an infinite loop?
for(; ;)
for (a = 0; a < 1; a--)
for (a = 0; ; a++)
for (a = −1; a < 1; a++)
Choose the odd one out from the following:
Return
Break
Continue
If-else
The while statement repeats the execution of a block only when the given condition is:
False
True
1
0
Which of the following is not a part of the looping construct?
Close
For
Break
Continue
Fill in the blanks:
When the statements are repeated sequentially a number of times in a program, the construct is known as ______.
For loop is also known as ______ controlled loop.
______ loop is called an exit controlled loop.
______ loop executes at least once, if the condition is false.
______ loop checks the condition first before its execution.
To find the sum of any ten numbers, the loop will run ______ times.
Predict the output:
The following is a segment of a program:
x = 1; y = 1;
if (n > 0)
{
x = x + l;
y = y +1;
}
What will be the value of x and y, if n assumes a value 1?
The following is a segment of a program:
x = 1; y = 1;
if (n > 0)
{
x = x + 1;
y = y + 1;
}
What will be the value of x and y, if n assumes a value 0?
Analyze the following program segment and determine how many times the body of the loop will be executed (show the working).
x = 5; y = 50;
while (x <= y)
{
y = y / x;
System.out.println(y);
}
What will be the output of the following code?
int m = 2;
int n = 15;
for (int i = 1; i < 5; i++)
m++;
--n;
System.out.println("m = " + m);
System.out.println("n = " + n);
Analyze the following program segment and determine how many times the loop will be executed. What will be the output of the program segment?
int k = 1, i = 2;
while (++i < 6)
k *= i;
System.out.println(k);
Give the output of the following program segment and also mention the number of times the loop is executed.
int a, b;
for (a = 6; b = 4; a <= 4; a = a + 6)
{
if (a % b == 0)
break;
}
System.out.println(a);
Give the output of the following program segment and also mention how many times the loop is executed :
int i;
for (i = 5; i > 10; i++)
System.out.println(i);
System.out.println(i * 4);
Rewrite the following program Using for loop:
int i = 1;
int d = 5;
do
{
d = d * 2;
System.out.println(d);
i++;
}
while (i <= 5);
Rewrite the following program Using while loop:
import java.util.*;
class Number
public static void main(String args[])
{
int n, r;
Scanner in = new Scanner(System.in);
System.out.println("Enter a number");
n = in.nextlnt();
do
(
r = n % 10;
n = n / 10;
System.out.println(r);
}
while (n != 0);
}
}
Answer the following questions:
What is for loop?
What are the parameters used in for loop?
Define the following with its construct:
Entry controlled loop
Define the following with its construct:
Exit controlled loop
Write down the syntax of do - while.
Write down the syntax of while loop.
What is the purpose of using break statement?
What is the purpose of using continue statement in a program?
State the difference between while and do-while loop.
What is an infinite loop?
Give an example of an infinite loop.
State the difference between while and do-while loop.
State one similarity between while loop and do-while loop.
Unsolved Programs:
Write the program in Java to display the first ten terms of the following series:
0, 1, 2, 3, 6, ................
Write the program in Java to display the first ten terms of the following series:
1, −3, 5, −7, 9, ................
Write the program in Java to display the first ten terms of the following series:
0, 3, 8, 15, ...................
Write the program in Java to display the first ten terms of the following series:
1, 11, 111, 1111, ...................
Write the program in Java to display the first ten terms of the following series:
l, 12, 123, 1234, ...................
Write the program in Java to find the sum of the following series:
S = 1 + 1 + 2 + 3 + 5 + ...................... to n terms
Write the program in Java to find the sum of the following series:
S = 2 − 4 + 6 − 8 + ................. to n
Write the program in Java to find the sum of the following series:
S = 1 + (1 + 2) + (1 + 2 + 3) + ........................ + (1 + 2 + 3 + ........................ + n)
Write the program in Java to find the sum of the following series:
S = 1 + (1 * 2) + (1 * 2 * 3) + ....................... + (1 * 2 * 3 * .......... * n)
Write the program in Java to find the sum of the following series:
S = 1 + `(1 + 2)/(1 "*" 2) + (1 + 2 + 3)/(1 "*" 2 "*" 3) + ............. + (1 + 2 + 3 .......... "n")/(1 "*" 2 "*" 3 .......... "n"))`
Write the program to find the sum of the following series:
S = a + a2 + a3 + .................... + an
Write the program to find the sum of the following series:
S = (a + 1) + (a + 2) + (a + 3) + ............... + (a + n)
Write the program to find the sum of the following series:
S = `a/2 + a/5 + a/8 + a/11 + ................. + a/20`
Write the program to find the sum of the following series:
S = `1/a + 2/a^2 + 3/a^3 + .................. " to n"`
Write the program to find the sum of the following series:
S = a − a3 + a5 − a7 + ..................... to n
Write a program to enter two numbers and check whether they are co-prime or not. [Two numbers are said to be co-prime, if their HCF is 1 (one).]
Sample Input: 14, 15
Sample Output: They are co-prime.
Write a program to input a number. Display the product of the successors of even digits of the number entered by user.
Input: 2745
Output: 15
[Hint: The even digits are: 2 and 4
The product of successor of even digits is: 3 * 5 = 15]
Write a program to input a number and check and print whether it is a Pronic number or not. (Pronic number is the number which is the product of two consecutive integers).
Examples: 12 = 3 × 4
20 = 4 × 5
42 = 6 × 7
A prime number is said to be Twisted Prime, if the new number obtained after reversing the digits is also a prime number. Write a program to accept a number and check whether the number is Twisted Prime or not.
Sample Input: 167
Sample Output: 761
167 is a Twisted Prime.
Write a program to input a number and check whether it is a prime number or not. If it is not a prime number then display the next number that is prime.
Sample Input: 14
Sample Output: 17
A number is said to be Duck if the digit zero is (0) present in it. Write a program to accept a number and check whether the number is Duck or not.
The program displays the message accordingly. (The number must not begin with zero)
Sample Input: 5063
Sample Output: It is a Duck number.
Sample Input: 7453
Sample Output: It is not a Duck number.
Write a program to input a number and display it into its Binary equivalent.
Sample Input: (21)10
Sample Output: (10101)2
A computerised bus charges fare from each of its passengers based on the distance travelled as per the tariff given below:
Distance (in km) | Charges |
First 5 km | ₹ 80 |
Next 10 km | ₹ 10/km |
More than 15 km | ₹ 8/km |
As the passenger enters the bus, the computer prompts Enter distance you intend to travel. On entering the distance, it prints his ticket and the control goes back for the next passenger. At the end of journey, the computer prints the following:
- the number of passenger travelled
- total fare received
Write a program to perform the above task.
[Hint: Perform the task based on user controlled loop]
A special two-digit number is such that when the sum of its digits is added to the product of its digits, the result is equal to the original two-digit number. Example: Consider the number 59.
Sum of digits = 5 + 9 = 14
Product of its digits = 5 x 9 = 45
Sum of the sum of digits and product of digits = 14 + 45 = 59
Write a program to accept a two-digit number. Add the sum of its digits to the product of its digits. If the value is equal to the number input, output the message “Special 2-digit number” otherwise, output the message “Not a special 2-digit number”
An abundant number is a number for which the sum of its proper divisors (excluding the number itself) is greater than the original number. Write a program to input a number and check whether it is an abundant number or not.
Sample input: 12
Sample output: It is an abundant number.
Explanation: Its proper divisors are 1, 2, 3, 4 and 6
Sum = 1 + 2 + 3 + 4 + 6 = 16
Hence, 12 is an abundant number.
Write a program to accept a number and check and display whether it is a spy number or not. (A number is spy if the sum of its digits equals the product of its digits.)
Example: consider the number 1124,
Sum of the digits = l + l+ 2 + 4 = 8
Product of the digits = 1×1 x2x4 = 8
Write a program to input a number and check whether it is a Harshad Number or not. [A number is said to be Harshad number, if it is divisible by the sum of its digits. The program displays the message accordingly.]
For example;
Sample Input: 132
Sum of digits = 6 and 132 is divisible by 6.
Output: It is a Harshad Number.
Sample Input: 353
Outpul: It is not a Harshad Number.
Write a program to display all Pronic numbers in the range from 1 to n.
Hint: A Pronic number is a number which is the product of two consecutive numbers in the form of n* (n + 1).
For example,
2, 6, 12, 20, 30, ................... are Pronic numbers.
You can multiply two numbers 'm' and 'n' by repeated addition method.
For example, 5 * 3 = 15 can be performed by adding 5 three times ⇒ 5 + 5 + 5 = 15. Similarly, successive subtraction of two numbers produces 'Quotient' and 'Remainder' when a number 'a' is divided by 'b' (a > b).
For example, 5/2 ⇒ Quotient = 2 and Remainder = 1
Follow steps shown below:
Process | Result | Counter |
5 − 2 | 3 | 1 |
3 − 2 | 1 | 2 |
Sample Output: The last counter value represents 'Quotient' ⇒ 2
The last result value represents 'Remainder' ⇒ 1
Write a program to accept two numbers. Perform multiplication and division of the numbers as per the process shown above by using switch case statement.
Using a switch statement, write a menu driven program to:
- generate and display the first 10 terms of the Fibonacci series 0, 1, 1, 2, 3, 5 ..............
The first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two. - find the sum of the digits of an integer that is input by the user.
Sample Input: 15390
Sample Output: Sum of the digits = 18
For an incorrect choice, an appropriate error message should be displayed.
Using switch statement, write 1a menu driven program for the following:
- To find and display the sum of the series given below:
S = x1 − x2 + x3 − x4 + x5 − ............................ − x20 - To find and display the sum of the series given below:
S = `1/a^2 + 1/a^4 + 1/a^6 + 1/a^8 + ...................... "to n terms"`
For an incorrect option, an appropriate error message should be displayed.
Write a menu driven program to perform the following tasks:
- Tribonacci numbers are a sequence of numbers similar to Fibonacci numbers, except that a number is formed by adding the three previous numbers. Write a program to display the first twenty Tribonacci numbers.
For example;
1, 1, 2, 4, 7, 13, ......................... - Write a program to display all Sunny numbers in the range from 1 to n.
[Hint: A number is said to be sunny number if square root of (n+l) is an integer.]
For example,
3, 8, 15, 24, 35, ...................... are sunny numbers.
For an incorrect option, an appropriate error message should be displayed.
Solutions for 1.8: Iterative Constructs in Java
![Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.8 - Iterative Constructs in Java Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.8 - Iterative Constructs in Java - Shaalaa.com](/images/computer-applications-english-class-10-icse_6:1e1eb1b47d2b4696b609e5cd9260118f.jpg)
Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.8 - Iterative Constructs in Java
Shaalaa.com has the CISCE Mathematics Computer Applications [English] Class 10 ICSE CISCE solutions in a manner that help students grasp basic concepts better and faster. The detailed, step-by-step solutions will help you understand the concepts better and clarify any confusion. Avichal solutions for Mathematics Computer Applications [English] Class 10 ICSE CISCE 1.8 (Iterative Constructs in Java) include all questions with answers and detailed explanations. This will clear students' doubts about questions and improve their application skills while preparing for board exams.
Further, we at Shaalaa.com provide such solutions so students can prepare for written exams. Avichal textbook solutions can be a core help for self-study and provide excellent self-help guidance for students.
Concepts covered in Computer Applications [English] Class 10 ICSE chapter 1.8 Iterative Constructs in Java are Introduction of Iterative Constructs in Java, Entry Controlled Loop, Exit Controlled Loop.
Using Avichal Computer Applications [English] Class 10 ICSE solutions Iterative Constructs in Java exercise by students is an easy way to prepare for the exams, as they involve solutions arranged chapter-wise and also page-wise. The questions involved in Avichal Solutions are essential questions that can be asked in the final exam. Maximum CISCE Computer Applications [English] Class 10 ICSE students prefer Avichal Textbook Solutions to score more in exams.
Get the free view of Chapter 1.8, Iterative Constructs in Java Computer Applications [English] Class 10 ICSE additional questions for Mathematics Computer Applications [English] Class 10 ICSE CISCE, and you can use Shaalaa.com to keep it handy for your exam preparation.