English

Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.8 - Iterative Constructs in Java [Latest edition]

Advertisements

Chapters

Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.8 - Iterative Constructs in Java - Shaalaa.com
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.


Review InsightEXERCISES
Review Insight [Page 120]

Avichal solutions for Computer Applications [English] Class 10 ICSE 1.8 Iterative Constructs in Java Review Insight [Page 120]

Review Insight | Q 1. | Page 120

Differentiate between a Null loop and an Infinite loop. 

Review Insight | Q 2. | Page 120

State one similarity between while loop and do-while loop. 

Review Insight | Q 3. (i) | Page 120

What is meant by an endless loop? 

Review Insight | Q 3. (ii) | Page 120

Give an example of an endless loop.

Review Insight | Q 4. | Page 120

Give an example to illustrate null loop. 

Review Insight | Q 5. | Page 120

What is a delay loop?

Review Insight | Q 6. | Page 120

Find the errors in the following program snippet: 

for (int k = 1; k <= 10; k--) 
      System.out.println(k);
Review Insight | Q 7. | Page 120

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; 
}
Review Insight | Q 8. | Page 121

Convert the following while loop to the corresponding for loop: 

int m = 5, n = 10;
while (n >= 1)
{
System.out.println(m*n);
n--;
}
Review Insight | Q 9. | Page 120

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; 
}
  1. Write the output of the program segment.
  2. How many times does the body of the loop get executed?
Review Insight | Q 10. | Page 120

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;
}
EXERCISES [Pages 122 - 127]

Avichal solutions for Computer Applications [English] Class 10 ICSE 1.8 Iterative Constructs in Java EXERCISES [Pages 122 - 127]

Multiple Choice Questions:

EXERCISES | Q I. 1. | Page 122

Which of the following statements will terminate the premature execution of a program?

  • System.exit(0)

  • Break

  • Stop

  • End

EXERCISES | Q I. 2. | Page 122

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++)
EXERCISES | Q I. 3. | Page 122

Choose the odd one out from the following: 

  • Return

  • Break

  • Continue

  • If-else

EXERCISES | Q I. 4. | Page 122

The while statement repeats the execution of a block only when the given condition is: 

  • False

  • True

  • 1

  • 0

EXERCISES | Q I. 5. | Page 122

Which of the following is not a part of the looping construct?

  • Close

  • For

  • Break

  • Continue

Fill in the blanks:

EXERCISES | Q II. 1. | Page 122

When the statements are repeated sequentially a number of times in a program, the construct is known as ______.

EXERCISES | Q II. 2. | Page 122

For loop is also known as ______ controlled loop. 

EXERCISES | Q II. 3. | Page 122

______ loop is called an exit controlled loop.

EXERCISES | Q II. 4. | Page 122

______ loop executes at least once, if the condition is false. 

EXERCISES | Q II. 5. | Page 122

______ loop checks the condition first before its execution. 

EXERCISES | Q II. 6. | Page 122

To find the sum of any ten numbers, the loop will run ______ times.

Predict the output:

EXERCISES | Q III. 1. (a) | Page 122

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?

EXERCISES | Q III. 1. (b) | Page 122

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?

EXERCISES | Q III. 2. | Page 122

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); 
  }
EXERCISES | Q III. 3. | Page 123

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);
EXERCISES | Q III. 4. | Page 123

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);
EXERCISES | Q III. 5. | Page 123

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);
EXERCISES | Q III. 6. | Page 123

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);
EXERCISES | Q IV. 1 | Page 123

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); 
EXERCISES | Q IV. 2. | Page 123

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:

EXERCISES | Q V. 1. (i) | Page 124

What is for loop? 

EXERCISES | Q V. 1. (ii) | Page 124

What are the parameters used in for loop?

EXERCISES | Q V. 2. (a) | Page 124

Define the following with its construct: 

Entry controlled loop

EXERCISES | Q V. 2. (b) | Page 124

Define the following with its construct:

Exit controlled loop 

EXERCISES | Q V. 3. (a) | Page 124

Write down the syntax of do - while.

EXERCISES | Q V. 3. (b) | Page 124

Write down the syntax of while loop.

EXERCISES | Q V. 4. (a) | Page 124

What is the purpose of using break statement?

EXERCISES | Q V. 4. (b) | Page 124

What is the purpose of using continue statement in a program?

EXERCISES | Q V. 5. | Page 124

State the difference between while and do-while loop.

EXERCISES | Q V. 6. (i) | Page 124

What is an infinite loop? 

EXERCISES | Q V. 6. (ii) | Page 124

Give an example of an infinite loop. 

EXERCISES | Q V. 7. (i) | Page 124

State the difference between while and do-while loop.

EXERCISES | Q V. 7. (ii) | Page 124

State one similarity between while loop and do-while loop. 

Unsolved Programs:

EXERCISES | Q VI. 1. (a) | Page 124

Write the program in Java to display the first ten terms of the following series: 

0, 1, 2, 3, 6, ................

EXERCISES | Q VI. 1. (b) | Page 124

Write the program in Java to display the first ten terms of the following series: 

1, −3, 5, −7, 9, ................ 

EXERCISES | Q VI. 1. (c) | Page 124

Write the program in Java to display the first ten terms of the following series:

0, 3, 8, 15, ...................

EXERCISES | Q VI. 1. (d) | Page 124

Write the program in Java to display the first ten terms of the following series:

1, 11, 111, 1111, ...................

EXERCISES | Q VI. 1. (e) | Page 124

Write the program in Java to display the first ten terms of the following series:

l, 12, 123, 1234, ...................

EXERCISES | Q VI. 2. (a) | Page 124

Write the program in Java to find the sum of the following series:

S = 1 + 1 + 2 + 3 + 5 + ...................... to n terms

EXERCISES | Q VI. 2. (b) | Page 124

Write the program in Java to find the sum of the following series:

S = 2 − 4 + 6 − 8 + ................. to n 

EXERCISES | Q VI. 2. (c) | Page 124

Write the program in Java to find the sum of the following series:

S = 1 + (1 + 2) + (1 + 2 + 3) + ........................ + (1 + 2 + 3 + ........................ + n)

EXERCISES | Q VI. 2. (d) | Page 124

Write the program in Java to find the sum of the following series: 

S = 1 + (1 * 2) + (1 * 2 * 3) + ....................... + (1 * 2 * 3 * .......... * n)

EXERCISES | Q VI. 2. (e) | Page 124

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"))`

EXERCISES | Q VI. 3. (a) | Page 124

Write the program to find the sum of the following series:

S = a + a2 + a3 + .................... + an

EXERCISES | Q VI. 3. (b) | Page 124

Write the program to find the sum of the following series:

S = (a + 1) + (a + 2) + (a + 3) + ............... + (a + n)

EXERCISES | Q VI. 3. (c) | Page 124

Write the program to find the sum of the following series:

S = `a/2 + a/5 + a/8 + a/11 + ................. + a/20`

EXERCISES | Q VI. 3. (d) | Page 124

Write the program to find the sum of the following series:

S = `1/a + 2/a^2 + 3/a^3 + .................. " to n"`

EXERCISES | Q VI. 3. (e) | Page 124

Write the program to find the sum of the following series:

S = a − a3 + a5 − a7 + ..................... to n 

EXERCISES | Q VI. 4. | Page 124

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. 

EXERCISES | Q VI. 5. | Page 124

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]

EXERCISES | Q Vi. 6. | Page 125

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

EXERCISES | Q VI. 7. | Page 125

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.

EXERCISES | Q VI. 8. | Page 125

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

EXERCISES | Q VI. 9. | Page 125

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.

EXERCISES | Q VI. 10. | Page 125

Write a program to input a number and display it into its Binary equivalent. 

Sample Input: (21)10

Sample Output: (10101)

EXERCISES | Q VI. 11. | Page 125

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:

  1. the number of passenger travelled
  2. total fare received

Write a program to perform the above task.
[Hint: Perform the task based on user controlled loop]

EXERCISES | Q VI. 12. | Page 125

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”

EXERCISES | Q VI. 13. | Page 126

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.

EXERCISES | Q VI. 14. | Page 126

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

EXERCISES | Q VI. 15. | Page 126

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.

EXERCISES | Q VI. 16. | Page 126

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. 

EXERCISES | Q VI. 17. | Page 126

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.

EXERCISES | Q VI. 18. | Page 126

Using a switch statement, write a menu driven program to:

  1. 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.
  2. 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.

EXERCISES | Q VI. 19. | Page 127

Using switch statement, write 1a menu driven program for the following:

  1. To find and display the sum of the series given below:
    S = x1 − x2 + x3 − x4 + x5 − ............................ − x20
  2. 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.

EXERCISES | Q VI. 20. | Page 127

Write a menu driven program to perform the following tasks:

  1. 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, .........................
  2. 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

Review InsightEXERCISES
Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.8 - Iterative Constructs in Java - Shaalaa.com

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.

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×