0% found this document useful (0 votes)
25 views

Computer array practise questions

For icse class 10 computer array program for practice
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
25 views

Computer array practise questions

For icse class 10 computer array program for practice
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
bees» Q.1: Tick the correct option for the following Questions : ilar types in consecutive index 1. The process si ¢ data items of a paseees toring d tail ingle alannah © double dimensi ana, 2, Which of the following is a valid array declaration : a) int al J=new int 7 int [ Jaznew int{3} (o) Int al I=new a3] (a) ine a sir A single dimensional array contains N elements. What are the start and the last Subse Inti (a) OandN-1 (b) OandN () LandN-1 @ Oandy TPS 4. By default a double dimensional array is organize - (a) column wise (b) row x column () column wise (@) column x toy 5. A double dimensional array is declared with m rows and n columns. What is the Start ang Ia et indexes of the array? @) ©@O& mn @) Gd) & m1, 2D) © OY & (m1, A) 0,0) & (ma, If int ar[ ] = {2, 5, 6, ,8 11)3, then which of the following is valid? (a) int p=ar(}.length; (b) int p= ar. length; (©) int p= ar lengthO; (A) int p-ariLengay 7. State the values of p and q, if int arf [] = {€ 2) 1, 2} 43, 4, 5 Hs: . Pp =ar. length; a= ar[1][2]* arf O][1]} +n (© p=2andgq=10 (@) p=1landge5 (a) p=2andq=5 (b) p=3andq=5 8. The size of the arrays int m[ ] = new int[ 5 ] and float mf ][] = new floatl 2 11 3] in byes xy (a) 20 and 24 (b) 18 and 24 (© 20 and 24 (@) 4and4 9. The positive integer enclosed within the [ ] brackets is known as: (a) superscript () subscript (© unsized array (@)_ None of these 10. If int [] n = { 8, 12, 25, 2, 2, 27, 6, 3, 3 js, what are the value of m and n from the following m = Math . pow( n[ 0], n[ 8] )s Math . sart( n[ 2] ) * Math . cbrt( n[ 5] )s n 5 () m=27.0,n=15.0 (a) m=150,n=2 (a) m=27,n=25 (b) m=27.0,n Q.2: Answer the Following Questions: 1. Define single dimensional array and double dimensional arrays. Give one example of each. 2. Define subscript and subscripted variable. 3. What is array initialization? Give an example. 4. What is the advantage of using arrays? 5. What is the use of length attribute? 6. Define selection sort technique. 7. Define linear search technique. 8. Define selection sort method. 9. Define binary search. When the binary search technique fails to work? 10. Perform the following operations: (i) Initialize 10 integers in a single dimensional array. (ii) Initialize double dimensional array with integers of dimension 3 rows and 3 columns. (iii) Initialize a character array with uppercase vowels. (iv) Initialize a character array with lowercase vowels. (v) Initialize an array with 15 fractional data items. ads mensional arr) Arrays (Single Dimensional and Double Dit NY y ammning Assignments: gram to initialize 10 integey a : - i a prone ch number. Also, pent aw &t array ar[ ]. Print the array horizontally with one ‘ Mabenween 3 UNO: Print sum ofall the even integers and sum of all the odd integers the array oaeeee 7 gram to initialize 15 integer elements iti a prog ements in an array e eleme! be positive or wa print all the integers of the array VARI: the elements may Pe get along wii e iti tive ers from the array. ig with the count of positive and count of negative inc ite . a program to accept °N’ from the user, declare an array of size N. Input integers into the Print the array elements in single line with one space along with greatest and smallest 1s from the array ite iirte a program to store average marks of 40 students in a single subscripted variable and print timber of students falling in the following categories in two col ‘Average Marks mns: Number of students 1-30 xx 31-50 x 51-70 ge 71-85 xx 86-100 7 Write a program to declare a single dimensional array of n integer elements (accept n from the user). Print only those elements which are prime numbers. Write a program to accept N from the user and declare an array arr{] of size N of double datatype. ‘Accept double type elements into the array and print each element after rounding. Write a program to declare a character array of size fifteen, accept the characters into the array and print the count of uppercase letters and count of lowercase letters from the array. Write a program to declare a character array of size ten, accept the characters into the array and print the count of uppercase vowels and count of lowercase vowels from the array. | Write a program to declare a character array of size twenty, accept the characters into the array and print the count of consonants from the array. Write a program to initialize two single dimensional array A{ } and B[ ] containing integers given below. Print elements of both the arrays separately, and also print whether both the arrays are identical or not. Let A[] = {2, 3, 6, 8) and BI J= (2, 3, 6, 8} so output “both the arrays are same” Let A[ ] = {2, 3, 6, 8) and BI J= (4, 3, 7, 8} so output “both the arrays are not same” |. Write a program to declare an array of size 15, accept the integers into the array and perform the following. * Print elements of the array in separate lines. * Print Palindrome numbers from the array. * Print Armstrong numbers from the array. ize N. Input i into the array and sort Write a pro «LN and declare an array AR{] of size N. Input integers into t andien them inne eae using bubble sort technique. Print the input array and the sorted array, Write B are an array perl ] of size 40. Input percentage of marks (in decimals) Stained bythe stutonta Into the array and cort them in doszending order using bubble sort ; i rks before and after the sorting. chnique, Print the percontaee ‘s ee BE el a ae N Input ntogers inte aod thee ‘2 program accept Nand selection sort technique. Print the input array and the sorted array. , es eases talmarks| J of size 30. Input total marks obtained by the Wrest ing caionsi s into the array an d ‘the total marks before and after the sorting. * Write a ay ar[] of program to declare an array oe Sort them in ascending order using selectio e sorting. \y size 40. Input height of 40 students into the array and ‘ort technique. Print the heights before and after be 17. 18. 19. 21, 22, 23. 24, 25. 26. 27. 28. Write a program to declare two arrays roll{ } (integer to store roll numbers) and per{ ] (douby to store percentage) of size 20 each. Input roll numbers and percentage into the appropriate ee Arrange the array roll[] in ascending order along with array per{] using selection sort. teenie Print the array containing roll numbers (roll{ }) and percentage (per{ }) before and after the sorting Write a program to declare a character array of size ten, accept uppercase characters into the ary, yo. and sort them in alphabetical order using bubble sort technique. Print the character ars before after the sorting. i Example: Input: ‘R’, ‘Z’, ‘A’, Q, M, ‘EY, ‘G’, 'S', ‘4’, ‘@ Output: Original array:R ZA QMEGSAQ Sorted array: A AE GMQQRSZ Write a program to declare a character array of size ten, accept lowercase characters into the array and sort them in reverse alphabetical order using selection sort technique. Print the character arrays before after the sorting, Example: Input: ‘r, ‘Z, ‘a’, ‘q, ‘my, ‘e’, ‘g's ‘a’, Output: Original array:R ZA QMEGSAQ Sorted array:zsrqqmgeaa 31 . Write a program to declare an array ar[] of size ten, accept integers into the array and perform the following operations: + Print elements of the array in separate lines. Print the greatest number and smallest number from the array. Define a class to perform linear search on a list of integers given below, to search for an element num input by the user. Display num along with index number/subscript, if num is found, otherwise display the message “Number not found”. 8, 5, 12, 67, 4, -6, 8, -9, 11, 25 Define a class to perform linear search on a list of characters given below, to search for acharacter element val input by the user. Display character val along with index number/subseript, ifitis found, otherwise display the message “Character not found” *P, °2, a, “oy mn’, ey gy ‘8, ‘a’, ‘qt Define a class to perform binary search on a list of integers given below already sorted in ascending order, to search for an element num input by the user. Display mum along with index number/subscript, if num is found, otherwise print a message “Search unsuccessful”. 8, 5, 7, 8, 12, 13, 17, 21, 23, 27, 30, 32, 35, 40, 49 Define a class to perform binary search on a list of integers given below already sorted in descending order, to scarch for an element input by the user. Display the clement along with index number/subscript, if it is found, otherwise print a message “Search unsuccessful”. 49, 40, 35, 32, 30, 27, 23, 21, 17, 13, 12, 8, 7, 5, 3 Define a class to perform binary search on a list of characters given below, to search for a character element val input by the user. Display character val along with index numbe subscript, if it is found, otherwise display the message “Character not found”. a, ‘c, a’, P, ¥, Ie, Ty 0", ‘phy Py ‘8? 5 Write a program to print the sum of negative numbers, sum of positive even numbers and s0m positive odd numbers from a list of numbers (N) entered by the user. ‘The list terminatet ‘ps the user enters a zero. Ics) pH : i ji Write a program to assign following set of values in an array and arrange them in ser 2008 order using Bubble Sort method. Ie Input : 5, 3, 8, 4, 9, 2, 1, 12, 98, 16 Output: 1, 2, 8, 4, 5, 8, 9,12, 16, 98 ger . Write a program to accept 15 integers into an array, assuming that no integer entered Se aw Perform selection Sort on the integers and then print them in ascending order. Arrays (Single Dimensional and Double Dimens!0 program to initialize the given data in jong with the sum of the given lamentaas array and find the minimum and maximum. 25418 ICSE 2007 rite ® alues # Numbers? Output ; Minimum value: 1 Maximum value: 5 Sum of the elements: 15 the annual examination results of 60 students in a class is tabulated as follows; ICSE 2009 mein. Subject A Subject B Subject ¢ a a >= rite a program to read the data, calculate and display the following : (a) Average mark obtained by each student, (b) Print the roll number and average mark of the student whose average mark is above 80. (¢) Print the roll number and average mark of the student whose average mark is below 40. 41. Write a program to store 6 elements in an array P, and 4 elements in array Q and produce a third array R, containing all the elements of arrays P and Q. Display the resultant array. Example: INPUT OUTPUT PU) atl Rt] 19 4 23 6 1 1 8 2 3 0 10 19 23 7 8 42 Write a program to perform binary search on the list of integers given below (that are arranged in ascending order), to search for an element input by user, if it is found display the element along with its position, otherwise display the message “Search element not found”. 5,7, 9, 11, 15, 20, 80, 45, 89, 97 ICSE 2010 33. Write a program to input and store weight of ten people. Sort and display them in Descending order using the Selection sort technique. ICSE 2011 4. White a program to input ten (10) integer elements in an array and sort them in Descending ie order using the Bubble sort technique. ICSE 2013 5 Write a program to accept the year of graduation from school as integers from the user. Using the Binary Search technique on the sorted array of integers, output the message “Record exists”, Year input is located in the array. If not, output the message “Record does not exist”, 3 {1982, 1987, 1993, 1996, 1999, 2003, 2006, 2007, 2009, 2010} ICSE 2014 " Write @ program to input and store roll numbers and marks in $ subjects of n number of students 'n four single dimensional arrays and display the remark based on average marks as given below: ICSE 2010 ReNHas ICSE 2015 Maika\\)) newark eae EXCELLENT eek DISTINCTION coud FIRST CLASS 40 - 59 PASS POOR Less Than 40 yY ; into an array of size 20 and perform the followin, 87, Write a program to input integer element: TSE thy, }) Display the largest number from the array. (i) Display the smallest number fond . a (iii) Display sum of all the elements of the array : : 38. wie a program to accept name and total marks of N students in two single subset ag name ] and totalmarks[ ]. Calculate and print: 2018 () The average of the total marks obtained by N numl [average = (sum of the total marks of all the students) / N] (ii) Deviation of each student's total marks with average: (deviation = total marks of a student - average] . . 39. Write a program to input 15 integer elements in an array and sort them in ascending order using the bubble sort technique. SE 2019 40. Define a class to perform binary search on a list of integers given below, to search for an element input by the user, if it is found display the element along with its position, otherwise display the message “Search element not found”. ICSE 2022 - Semester 2 41. Define a class to declare a character array of size ten, accept the characters into the array and display the characters with the highest and lowest ASCII (American Standard Code for Information Interchange) value. ICSE 2022 - Semester 2 Example: Input: R,, ‘2’, ‘aq’, ‘A’, ‘N’, ‘p’, ‘m’, ‘U’, ‘Q’, Output: Character with highest ASCII value = z Character with lowest ASCII value = A 42. Define a class to declare an array of size twenty of double datatype, accept the elements into the array and perform the following: ICSE 2022 - Semester 2 - Calculate and print the product of all the elements. + Print the square of each element of the array. 43. Write a program to initialize the following integers in a double dimensional array of 3 rows and 8 columns, and print them in the form of matrix of rows and 3 columns, 2, 5, 6, 7, 8, 9,2, 1,4 44. Write a program to initialize the following integers in a double dimensional array of 4 rows and 3 columns, and print them in the form of matrix of 4 rows and 3 columns. 2, 5, -6, 7, -8, 9, 2, 1-4, 8, 12, 20 45. Write a program to accept integers into a double dimensional array in 3 rows and 4 columns, and perform the following: + Print the array in the form of matrix of 3 x 4. + Print the sum of all the elements of the matrix. Example: If the elements of the matrix are: 1, 2, 8, 4, 5, 6, 7, 8, 9, 1, 2, 3 Output: 1 2 3 4 6° 6 Th eng Ome li lee sum of all the elements = 51 ber of students. 46. Write a program to accept integers in a square matrix of size N, ai + Print the square matrix of N x N. + Print the sum of the elements of each row separately. ind perform the following: Example: If n = 8 and the elements of the matrix as: 1, 2, 3, 4, 5, 6, 7, 8, 9 | Output: 1 2 3 4 5 6 | 7 8 9 Arrays (Single Dimensfonal and Double Dimensional Array) NA sum of row = 6 sum of row = 15 sum of row = 24 gram to accept integers into a double dimensional array of m x n, where m is the ‘Take m and n as input from the user and perform yuNsle Tryows and n is the number of columns, sur ng operations: fran the array matrix of the order m xn, Frit ehe sum of the elements of each column separately. Ifm = 2, n = 3 and the elements of the matrix as: 4, 5, 6, 7, 8, 9 Output: a 5 6 © 6 sample? sum of column = 11 sum of column = 13 sum of column = 15 grit a program to accept integers in a square matrix of size n, and perform the following: + Print the square matrix of n x n. + Print the sum of the left diagonal or primary diagonal elements. Example: If n = 3 and the elements of the matrix as: 9, 8, 7, 6, 5, 4, 3, 2, 1 Output: 9 8 1 6 ij 4 3 2 1 The sum of the elements of left or primary diagonal = 15 (means 9, 5, 1) {4 Write a program to accept integers in a square matrix of size n, and perform the following: * Print the square matrix of n x n. + Print the product of the right diagonal or secondary diagonal elements. Example: If n = 3 and the elements of the matrix as: 4, 5, 6, 1, 2, 3, 8, 2, 7 Output: 4 5 6 1 2 3 8 2 7 ‘The product of the right or secondary diagonal elements = 96 (means 6, 2, 8) trite a program to input integers into a double dimensional array of the order M rows and N ‘olumns, and perform the following: Print the array in the form of matrix of Mx N. : Print the sum of only boundary or outer elements of the matrix. ‘ample: Input M = 3, N= 4, Matrix=[2 38 4° 2 a is 2 a 9 8 2 6 The sum of boundary or outer elements = 45 (boundary values = 2+3+44+2+5+6+2+8+044 = 45)

You might also like