Page 325 - computer science (868) class 11
P. 325

B.  Fill in the blanks:
                    1.  Index in an array starts with …………………  .
                    2.  ………………… search is also known as sequential search.
                    3.  ………………… is the process of combining two or more arrays.
                    4.  Array can be initialised using ………………… as a separator surrounded by curly braces.
                    5.  The ………………… class is used to take input from the user in arrays.
                 C.  Answer the following questions:
                    1.  What is a 2D array?
                    2.  What do you mean by sorting?
                    3.  Define bubble sort.
                    4.  What is insertion sort?
                 D.  Unsolved Programs:
                    1.  Write a program in Java to input 10 positive and negative numbers each and calculate the following:
                        a.  sum of odd numbers in an array
                        b.  product of all the multiples of 7.
                    2.  Write a program in Java to input 20 names in an array and print the names in ascending order using the bubble sort method.
                    3.  Write a program in Java to store 25 numbers in a single-dimensional array and arrange them in descending order by using
                       insertion sort.
                    4.  Write a Java program to input 10 numbers and print the prime numbers only.
                    5.  Write a program in Java to create an array of 5 elements and using switch case do the following.
                        Case 1: prints the sum of all the prime numbers
                        Case 2: print all the odd negative numbers
                    6.  Write a Java program to create an array of size 2 × 3 and print the factorial of all the numbers separately.
                    7.  Write a program in Java to accept  the item names and prices of some items in two single-dimensional arrays and calculate the
                       total amount to be paid by the customer. Display in the following manner:
                         Item Name      Price
                             –           –
                             –           –
                       Total Amount      –
                    8.  Write a Java program to input "n" numbers and store the odd numbers and even numbers separately in two different arrays.
                    9.  Write a program in Java to accept the names and marks in computer science of forty students in an array and then print the
                       names and marks of students according to their merit.
                    10.  Write a Java program to find the common elements between two arrays A and B and print them.
                    11.  Write a program in Java that reads the following list of countries and their respective cities into two separate one-dimensional
                       arrays. The program should accept the name of a country as input and give the name of the corresponding city as an output. The
                       program should display an error message when the user enters the country which is not mentioned in the given list. To stop the
                       program, "XXX" is to be entered as input.
                           GERMANY         BERLIN
                            NEPAL            KATMANDU
                            JAPAN            TOKYO
                           CANADA           MONTREAL
                           IRAQ             BAGHDAD
                    12.  The annual examination result of 50 students in a class is tabulated as follows:
                         Roll No.  Subject A  Subject B  Subject C
                            –         –          –          –
                        Write a Java program to read the data, calculate and display the following:
                        a.  Average marks obtained by each student.
                        b.  Print the roll number and average marks of the students whose average mark is above 80.


                                                                                                                       323
                                                                                                              Arrays   323
   320   321   322   323   324   325   326   327   328   329   330