English

Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.9 - Nested Loop [Latest edition]

Advertisements

Chapters

Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.9 - Nested Loop - Shaalaa.com
Advertisements

Solutions for Chapter 1.9: Nested Loop

Below listed, you can find solutions for Chapter 1.9 of CISCE Avichal for Computer Applications [English] Class 10 ICSE.


Review InsightEXERCISES
Review Insight [Pages 143 - 144]

Avichal solutions for Computer Applications [English] Class 10 ICSE 1.9 Nested Loop Review Insight [Pages 143 - 144]

Review Insight | Q 1. | Page 143

What is meant by labelled break statement?

Review Insight | Q 2. | Page 143

Find the error:

int j, k;
for (k = 1; k <= 10; k--)
{
    for (j = 1; j >= k; j++)
        System.out.printIn(j);
}
Review Insight | Q 3. | Page 143

List the differences between break and continue statements.

Review Insight | Q 4. | Page 143

Predict the output:

int i, j;
for (j = 1; j <= 5; j += 2)
{
     for (k = 1; k <= j; k++)
        System.out.print(k);
System.out.println();
}
Review Insight | Q 5. | Page 143

Study the snippet given below and answer the following questions:

int j, k, p = -1;
for (j = -2; j <= 1; j++)
{
     for (k = j; k <= 0; k++)
       k = Math.max(j * k, p);
System.out.print(k);
p = p + 2;
} 
  1. How many times will the outer loop run?
  2. Predict the output.
Review Insight | Q 6. | Page 143

Predict the output:

int k = 5; j;
   while (k >= 1)
   {
      j = 1
   while (j <= k)
     {
     System.out.print(j);
     j++
     }
   System.out.println();
   k--;
   }
Review Insight | Q 7. | Page 144

Predict the output:

int i, j;
first:
for (i = 1; i < 10; i = i + 2)
{
      for (j = 3; j >= 1; j = j - 2)
      {
      if (i > 5)
        break first;
      System.out.println("i=" + i + ",j=" + j);
      }
}
Review Insight | Q 8. | Page 144

Predict the output:

int i, j;
first:
for (i = 0; i < 5; i = i + 2)
{
     second:
     for (j = 1; j <= 10; j++)
     {
     System.out.println("i=" + i + "j=" +);
     if (j == 2)
       break second;
     }
}
EXERCISES [Pages 144 - 151]

Avichal solutions for Computer Applications [English] Class 10 ICSE 1.9 Nested Loop EXERCISES [Pages 144 - 151]

Multiple Choice Questions:

EXERCISES | Q I. 1. | Page 144

A loop within another loop is called a: 

  • Double loop

  • Embedded loop

  • Circular loop

  • Nested loop

EXERCISES | Q I. 2. | Page 144

The ______ break is used to terminate the outer loop from the block of inner loop. 

  • Level

  • Labelled

  • Unlabelled

  • Forced

EXERCISES | Q I. 3. | Page 144

Which of the following keywords can be used to terminate a switch case as well as a loop construct? 

  • Continue

  • Void

  • Break

  • Stop

EXERCISES | Q I. 4. | Page 145

Given: for (i = 0; i < 4; i++)
                for (j = 1; j < 4; j++)
                .............................
                 Statement
                .............................

How many times the above nested loop will iterate?

  • 12 times

  • 8 times

  • 4 times

  • 16 times

EXERCISES | Q I. 5. | Page 145

Which of the following statements is not valid for a nested loop?

  • The break statement can be used to terminate inner as well as outer loop.

  • The outer loop can be terminated from the block of inner loop.

  • The inner loop can be terminated from the block of outer loop.

  • The inner loop repeats the execution a number of times for each iteration of the outer loop. 

Write whether the following statements are True/False:

EXERCISES | Q II. 6. | Page 145

Nested loop contains a single loop.

  • True

  • False

EXERCISES | Q II. 7. | Page 145

When break statement is applied, it terminates the loop.

  • True

  • False

EXERCISES | Q II. 3. | Page 145

The outer loop follows next iteration when iterations of inner loop is over.

  • True

  • False

EXERCISES | Q II. 4. | Page 145

Nested loop means the using of two or more loops in a program.

  • True

  • False

EXERCISES | Q II. 5. | Page 145

Labelled break statement allows the next iteration of the loop from any place of looping structure. 

  • True

  • False

EXERCISES | Q II. 6. | Page 145

In a nested loop, break and continue can be used simultaneously.

  • True

  • False

Answer the following questions:

EXERCISES | Q III. 1. | Page 145

What is a nested loop?

EXERCISES | Q III. 2. | Page 145

Write down the syntax of a nested for loop. 

EXERCISES | Q III. 3. | Page 145

What action will you take to terminate an outer loop from the block of an inner loop? 

EXERCISES | Q III. 4. (i) | Page 145

What is significance of break outer in a nested loop? 

EXERCISES | Q III. 4. (ii) | Page 145

What is significance of continue outer in a nested loop? 

EXERCISES | Q III. 5. (a) | Page 145

Write down the constructs (syntax) of Nested do-while loop.

EXERCISES | Q III. 5. (b) | Page 145

Write down the constructs (syntax) of Nested while loop.

Unsolved Programs:

EXERCISES | Q IV. 1. (a) | Page 145

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

S = 1 + `3/(2!) + 5/(3!) + 7/(4!) + ................ "to n"`

EXERCISES | Q IV. 1. (b) | Page 145

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

S = `a + a/(2!) + 3/(3!) + a/(4!) + ......................... + a/(n!)`

EXERCISES | Q IV. 1. (c) | Page 145

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

S = `a - a/(2!) + a/(3!) - a/(4!) + ............................ "to n"`

EXERCISES | Q IV. 1. (d) | Page 145

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

S = `a/(2!) - a/(3!) + a/(4!) - a/(5!) + ............................... + a/(10!)`

EXERCISES | Q IV. 1. (e) | Page 145

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

S = `2/a + 3/a^2 + 5/a^3 + 7/a^4 + ........................... "to n"`

EXERCISES | Q IV. 2. | Page 145

Write a program to input two numbers and check whether they are twin prime numbers or not. 

Hint: Twin prime numbers are the prime numbers whose difference is 2. 
For example, (5, 7), (11, 13), ............................ and so on.

EXERCISES | Q IV. 3. | Page 146

Write a program to display all the numbers between 100 and 200 which don't contain zeros at any position. 

For example, 111, 112, 113, ..............................., 199 

EXERCISES | Q VI. 4. | Page 146

Write a program to display all prime palindrome numbers between 10 and 1000.

Hint: A number which is prime as well a palindrome is said to be Prime Palindrome number.
For example, 11, 101, 131, 151, ......................... 

EXERCISES | Q VI. 5. | Page 146

In an entrance examination, students have appeared in English, Maths and Science papers. Write a program to calculate and display average marks obtained by all the students. Take number of students appeared and marks obtained in all three subjects. by every student along with the name as inputs. 

Display the name, marks obtained in three subjects and the average of all the students. 

EXERCISES | Q VI. 6. | Page 146

Write a program in Java to enter a number containing three digits or more. Arrange the digits of the entered number in ascending order and display the result. 

Sample Input: Enter a number 4972
Sample Output: 2, 4, 7, 9

EXERCISES | Q VI. 7. | Page 146

Write a program to input a number and check whether it is Magic Number or not. Display the message accordingly.

A number is said to be a magic number if the eventual sum of digits of the number is one.
Sample Input : 55
Then, 5 + 5 = 10, 1 + 0 = 1
Sample Output: Hence, 55 is a Magic Number.
Similarly, 289 is a Magic Number. 

EXERCISES | Q VI. 8. | Page 146

A number is said to be Multiple Harshad number, when divided by the sum of its digits, produces another Harshad Number. Write a program to input a number and check whether it is a Multiple Harshad Number or not. 

(When a number is divisible by the sum of its digit, it is called Harshad Number).

Sample Input: 6804
Hint: 6804 ⇒ 6+8+0+4 = 18 ⇒ 6804/18 = 378
          378 ⇒ 3+7+8= 18 ⇒ 378/18 = 21
          21 ⇒ 2+1 = 3 ⇒ 21/3 = 7

Sample Output: Multiple Harshad Number 

EXERCISES | Q VI. 9. (a) | Page 146

Write the program in Java to display the following pattern:

1
3     1
5     3     1
7     5     3     1 
9     7     5     3     1 

EXERCISES | Q VI. 9. (b) | Page 146

Write the program to display the following pattern:

1     2     3     4     5
6     7     8     9
10   11   12
13   14
15

EXERCISES | Q VI. 9. (c) | Page 146

Write the program to display the following pattern:

15    14    13    12    11
10     9      8      7
6       5      4
3       2
1

EXERCISES | Q VI. 9. (d) | Page 146

Write the program to display the following pattern:

1
1     0
1     0     1
1     0     1     0
1     0     1     0     1

EXERCISES | Q VI. 9. (e) | Page 146

Write the program to display the following pattern:

5     5     5     5     5
       4     4     4     4
              3     3     3
                     2     2
                            1

EXERCISES | Q VI. 9. (f) | Page 146

Write the program to display the following pattern:

1     2     3     4     5
2     2     3     4     5
3     3     3     4     5
4     4     4     4     5
5     5     5     5     5

EXERCISES | Q VI. 9. (g) | Page 147

Write the program to display the following pattern:

*
*     #     
*     #     *
*     #     *     #
*     #     *     #     *

EXERCISES | Q VI. 9. (h) | Page 147

Write the program to display the following pattern:

5     4     3     2     1
5     4     3     2     
5     4     3
5     4
5

EXERCISES | Q VI. 9. (i) | Page 147

Write the program to display the following pattern:


2     3
4     5     6
7     8     9     10
11   12   13    14    15

EXERCISES | Q VI. 10. | Page 147

Write a program to generate a triangle or an inverted triangle till n terms based upon the user's choice. 

Example 1: Example 2:

Input: Type 1 for a triangle and Type 2 for an inverted triangle Enter your choice 1
Enter the number of terms 5

Input: Type 1 for a triangle and Type 2 for an inverted triangle Enter your choice 2
Enter the number of terms 6

Sample Output:

1
2     2
3     3     3
4     4     4     4   
5     5     5     5     5 

Sample Output:

6     6     6     6     6     6
5     5     5     5     5    
4     4     4     4    
3     3     3
2     2   

EXERCISES | Q VI. 11. | Page 147

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

(i) To print Floyd’s triangle [Given below]

1

2      3

4      5       6

7      8       9      10

11    12    13     14    15

(ii) To display the following pattern:

I

I     C

I     C      S

I     C      S     E

For an incorrect option, an appropriate error message should be displayed. 

EXERCISES | Q VI. 12. | Page 147

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

  1. To input a number and display only those factors of the numbers which are prime.
    Sample Input: 84
    Sample Output: 2, 3, 7
  2. A program that displays the multiplication table from 1 to 10, as shown: 
    1 2 3 4 5 6 7 8 9 10
    2 4 6 8 10 12 14 16 18 20
    3 6 9 12 15 18 21 24 27 30
    .....................................................
    .....................................................
    .....................................................
    9 18 27 36 45 54 63 72 81 90
    10 20 30 40 50 60 70 80 90 100

Case-Study Based Questions (Solved):

EXERCISES | Q I. 1. | Page 148

One of the major disadvantages of the high-level language is that the machine can't understand this language directly. So, we need translators/language processors to convert the instructions written in high-level language into equivalent instructions that can be understood by the machine and operated upon by the CPU. 

Based on the above discussion, answer the following questions:

  1. Which of the following is not a high-level language?
    1. BASIC Language
    2. Machine Language
    3. Java Language
    4. Python language
  2. Which of the following codes is used by the language processor to generate machine code?
    1. Source code
    2. Object code
    3. Input code
    4. High-level code
  3. Which of the following is not a language translator?
    1. Compiler
    2. Interpreter
    3. Converter
    4. Assembler
  4. In machine code, the instructions are written using digits:
    1. 1's and 0's
    2. 1's and 2's
    3. In base 8
    4. In base 10
EXERCISES | Q I. 2. | Page 148

The high level programming languages are mainly categorized into Procedure Oriented Programming (POP) and Object Oriented Programming (OOP). Normally, we use a flow chart to represent the flow of control from one function to another. In POP, the functions share global data which can move freely from one function to the other. However, the Object Oriented Programming does not allow data to flow freely from one function to another. In this system, the complete problem is decomposed into a number of entities called the objects. 

Based on the above discussion, answer the following questions:

  1. Which of the following is not a Procedure Oriented Programming language?
    1. COBOL
    2. FORTRAN
    3. Python
    4. BASIC
  2. Which of the following statements is valid for an Object Oriented Programing?
    1. The data can move freely in the program.
    2. The function can move freely in the program.
    3. The data and function are wrapped together in the program.
    4. The data can't communicate with the function in the program.
  3. Which of the following is not an Object Oriented Programming language?
    1. Ruby
    2. C language
    3. Smalltalk
    4. C++
  4. Name the unique entity which contains data and functions together in an Object Oriented Programming language.
    1. code
    2. object
    3. article
    4. item
EXERCISES | Q I. 3. | Page 148

Each individual component used in Java statements is called a token. Each token carries a special meaning and takes active part in effective execution of the program. Some of the tokens include literals, identifiers, punctuators, operators, etc. Literals are the constants whereas, the variables are the type of identifiers. The operators are the tokens, used to perform arithmetical and logical operations.

Based on the above discussion, answer the following questions:

  1. Which of the following is not a literal?
    1. P
    2. 'P'
    3. −99.99
    4. "Java"
  2. Which of the following is an operator?
    1. **
    2. //
    3. */
    4. ||
  3. Which of the following statements is correct?
    1. All the lowercase and uppercase letters are tokens.
    2. The semicolon (;) sign is not a token.
    3. All the variables are identifiers.
    4. All the identifiers are variables.
  4. Which of the following is not a token in Java language?
    1. Operators
    2. Assignment
    3. Separators
    4. Comments
EXERCISES | Q I. 4. | Page 149

Scanner class is the latest development in Java which allows the user to read values of various data types. It is defined within a package that must be included in the program to avail its inbuilt facilities. An object of scanner class must be created to accept the value of a specific data type. One of the advantages of Scanner class over InputStreamReader is that the values can be entered using less number of statements.

Based on the above discussion, answer the following questions:

  1. While designing Java program, the keyword ______ is used to include the package of scanner class.
    1. include
    2. import
    3. introduce
    4. insert
  2. What will be filled in the statement given below:
    Scanner sc = ______ Scanner (System.in);
    1. key
    2. def
    3. new
    4. scan
  3. Which of the following package will you use to avail scanner class?
    1. Java.Utility
    2. Java.util
    3. Java.io
    4. Java.scanner.class
  4. Which of the following statements is true for a scanner class?
    1. It doesn't accept float type values as an input.
    2. It accepts a word but not a sentence as an input.
    3. It doesn't accept a single character as an input.
    4. It accepts numeric as well as alphanumeric values as an input.
EXERCISES | Q I. 5. | Page 149

A loop is a repetitive construct used to repeat execution of a block of statements. The for and while loops will not execute even once, if the condition is false in the beginning. The number of iterations in a loop can be determined by the number of repetitions made till the given condition is true. The condition is checked in the beginning and at the end of while and do-while loops, respectively. 

Based on the above discussions, answer the following questions:

  1. Which of the following is an exit controlled loop?
    1. for loop
    2. while loop
    3. do-while
    4. all of the above
  2. In the given snippet, how many time the iterations of the loop will take place?
    int n = 1000;
    while (n > 10)
    n = n / 10;

    1. 1 time
    2. 0 time
    3. 2 times
    4. 3 times
  3. Which one of the following loops will not be executed even once?
    1. for (k = 1; k <= 100; k++ );
    2. for (k = 10; k < 1; k++ );
    3. for (k = 1; k >= 1; k++ );
    4. for (k = 0; k < 10, k++ );
  4. Predict the output when the following program snippet is executed?
    int n = 1000; 
    do 
      n = n / 10; 
    while (n > 10);
    System.out.println(n); 
    1. 1
    2. 100
    3. 10
    4. 0

Case-Study based questions (Unsolved):

EXERCISES | Q II. 1. | Page 150

Generally, a computer language uses either compiler or interpreter (a set of programs) to convert source code into object code. But Java, a case sensitive language, uses both the translators (i.e., compiler as well as interpreter). Firstly, compiler converts the Java source code into an intermediate code which is further converted into machine code with the help of an interpreter.

Based on the above discussion, answer the following questions:

  1. Which of the following statement is true?
    1. Java compiler is a hardware.
    2. Java compiler is a software but interpreter is a hardware.
    3. Both the translators are hardware.
    4. Both the translators are software.
  2. The intermediate code is referred to as:
    1. Byte code
    2. Assembly code
    3. ASCII code
    4. Unicode
  3. Java interpreter is also known as:
    1. Artificial machine
    2. Virtual machine
    3. Real machine
    4. Normal machine
  4. What is meant by a case sensitive language?
    1. It understands only lowercase letters.
    2. It understands only uppercase letters.
    3. It distinguishes between lowercase and uppercase letters.
    4. It doesn't distinguish between lowercase and uppercase letters.
EXERCISES | Q II. 2. | Page 150

An operator is basically a symbol which performs arithmetical and logical operations to yield meaningful results. There are three types of operators used to perform any operation in Java programming. They are arithmetical, relational and logical operators. The arithmetical operators are used to perform arithmetical calculations. They are unary, binary and ternary operators. The syntax of using ternary operator is: 

variable = (condition) ? expression1 : expression2; 

Based on the above discussion, answer the following questions:

  1. A / An ______ operator works on a single operand.
    1. binary
    2. relational
    3. unary
    4. ternary
  2. Which of the following is not a logical operator?
    1. ++
    2. &&
    3. ||
    4. !
  3. Which of the following constructs is equivalent to the ternary operator in Java language?
    1. if
    2. if-else
    3. nested if
    4. switch-case
  4. Which of the following is a relational operator?
    1. &
    2. $
    3. !=
    4. !
EXERCISES | Q II. 3. | Page 151

Functions are the built-in modules that can be used in our program to perform a specific operation. There are some mathematical functions that are used for specific functions. For example, we can use Math.sqrt() function to return square root of a positive number, Math.random() and Math.ceil() to return random number in a range of numbers to return the next higher integer number. 

Based on the above discussion, answer the following questions:

  1. What will be displayed, if the following statement is executed?
    System.out.println(Math.sqrt(−25));
    1. Infinite
    2. −5.2
    3. NaN
    4. Logical error
  2. Math.random( ) function returns a random number in the range:
    1. between 0 and 1
    2. between −1 to 0
    3. between −1 to 1
    4. None of the above
  3. Which of the following function will return the next higher integer number?
    1. Math.max()
    2. Math.min()
    3. Math.floor()
    4. Math.ceil()
  4. Which of the following statement is true for Math.max()?
    1. It will always result in int type value.
    2. It will always result in double type value.
    3. The resultant data type will depend upon the type of arguments.
    4. It will return float type, if arguments are double type.
EXERCISES | Q II. 4. | Page 151

Java, like all other programming languages uses some statements that allow us to check a condition and execute certain parts of a code depending on whether the condition is true or false. Such statements are called conditional statements. We can also use a conditional statement within another conditional statement. The inner conditional statement is executed only when the outer condition is true. The conditional statement can also be a multiple branching statement. 

Based on the above discussion, answer the following questions:

  1. Which of the following is not a decision making statement?
    1. if-else
    2. if
    3. break
    4. if-else-if 
  2. A conditional statement used within another conditional statement is known as ______.
    1. nested conditional statement
    2. embedded conditional statement
    3. accumulated conditional statement
    4. None of the above
  3. Which of the following is called as multiple branching statement?
    1. if and only if
    2. switch
    3. case
    4. pause
  4. Which of the following is not a component of multiple branching statement?
    1. break
    2. default
    3. case
    4. pause
EXERCISES | Q II. 5. | Page 151

The following program segment calculates the norm of a number. Thenorm of a number is the square root of sum of squares of all the digits of the number. 

Sample Input: 68
Sample Output: The norm of 68 is 10
[Hint: 6x6 + 8x8 = 36 + 64 = 100
The square root of 100 is 10. Hence, norm of 68 is 10] 

There are some places in the program left blank marked with ?1?, ?2?, ?3? and ?4? to be filled with variable/ function/ expression. 

Scanner in = new Scanner(System.in);
int num;
int d, s = 0; 
num = ..... ?1? .....
while (....?2?....)
{
d = n % 10; 
s = ....?3?....; 
n = n / 10;
}
System.out.println("The norm of" + num + "is" + ...?4?...);

Based on the above discussion, answer the following questions:

  1. Which of the following will be filled in place of ?1?
    1. in.nextlnteger;
    2. in.Nextlnt();
    3. in.nextlnt()
    4. in.nextint();
  2. What will you fill in place of ?2?
    1. num > 0
    2. num < 0
    3. num > 1
    4. num = 0
  3. What will you fill in place of ?3?
    1. s + d * d
    2. s * d + d
    3. s * s + d
    4. s + d
  4. What will you fill in place of ?4?
    1. Math.sqrt(s)
    2. Math.SQRT(s)
    3. Math.sqrt(n)
    4. Math.sqrt(num)

Solutions for 1.9: Nested Loop

Review InsightEXERCISES
Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.9 - Nested Loop - Shaalaa.com

Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.9 - Nested Loop

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.9 (Nested Loop) 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.9 Nested Loop are Introduction of Nested Loop, Types of Nested Loops.

Using Avichal Computer Applications [English] Class 10 ICSE solutions Nested Loop 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.9, Nested Loop 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×