{"id":120363,"date":"2023-04-23T10:00:41","date_gmt":"2023-04-23T04:30:41","guid":{"rendered":"https:\/\/www.aplustopper.com\/?p=120363"},"modified":"2023-04-24T09:54:50","modified_gmt":"2023-04-24T04:24:50","slug":"plus-two-computer-application-chapter-wise-questions-and-answers-chapter-2","status":"publish","type":"post","link":"https:\/\/www.aplustopper.com\/plus-two-computer-application-chapter-wise-questions-and-answers-chapter-2\/","title":{"rendered":"Plus Two Computer Application Chapter Wise Questions and Answers Chapter 2 Arrays"},"content":{"rendered":"
Question 1.
\nFrom the following which is not true for an array
\n(a) It is easy to represent and manipulate array variable
\n(b) Array uses a compact memory structure
\n(c) Readability of program will be increased
\n(d) Array elements are dissimilar elements
\nAnswer:
\n(d) Array elements are dissimilar elements.<\/p>\n
Question 2.
\nConsider the following declaration. int mark (50).
\nIs it valid? If no give the correct declaration.
\nAnswer:
\nIt is not valid. The correct declaration is as follows, int mark[50]. Use square brackets instead of parenthesis.<\/p>\n
Question 3.
\nConsider the following declaration. int mark[200].
\nThe index of the last element is____.
\nAnswer:
\n199.<\/p>\n
Question 4.
\nConsider the following declaration int mark[200]
\nThe index of the first element is_____
\nAnswer:
\n0.<\/p>\n
Question 5.
\nConsider the following int age[4]={15, 16, 17, 18};
\nFrom the following which type of initialisation is this.
\n(a) direct assignment
\n(b) along with variable declaration
\n(c) multiple assignment
\n(d) None of these
\nAnswer:
\n(b) along with variable declaration<\/p>\n
Question 6.
\nFrom the following which is used to read and display array elements
\n(\u0430) loops
\n(b) if
\n(c) switch
\n(d) if else ladder
\nAnswer:
\n(a) loops<\/p>\n
Question 7.
\nWrite down the corresponding memory consumption in bytes<\/p>\n
Answer:<\/p>\n
Question 8.
\nConsider the following intage[4] = {12, 13, 14};
\ncout<<age[3]; What will be the output?
\n(\u0430) 14
\n(b) 12
\n(c) 13
\n(d) 0
\nAnswer:
\n(d) 0<\/p>\n
Question 9.
\nThe elements of 2-dimensional array can be read using_____loop
\nAnswer:
\nnested loop.<\/p>\n
Question 10.
\n_____is the process of reading \/ visiting elements of an array
\nAnswer:
\ntraversal.<\/p>\n
Question 11.
\nAnjaly wants to read the 10 marks that already stored in an array and find the total. This process is known as_____
\n(a) insertion
\n(b) deletion
\n(c) traversal
\n(d) linear search
\nAnswer:
\n(c) traversal<\/p>\n
Question 12.
\nThe elements of an array of size ten are numbered from____to___.
\nAnswer:
\n0 to 9.<\/p>\n
Question 13.
\nElement mark[6] is which element of the array?
\n(a) The sixth
\n(b) the seventh
\n(c) the eighth
\n(d) impossible to tell
\nAnswer:
\n(b) the seventh<\/p>\n
Question 14.
\nWhen a multidimensional array is accessed, each array index is
\n(a) Separated by column.
\n(b) Surrounded by brackets and separated by commas.
\n(c) Separated by commas and surrounded by brackets.
\n(d) Surrounded by brackets.
\nAnswer:
\n(d) surrounded by brackets<\/p>\n
Question 15.
\nWrite a C++ statement that defines a string variable called ‘name’ that can hold a string of upto 20 characters.
\nAnswer:
\nchar name[21];<\/p>\n
Question 16.
\n_____is a collection of elements with same data type
\nAnswer:
\nArray<\/p>\n
Question 17.
\nFollowing are some of the statements regarding array. Identify the correct statement.
\n(a) Array is a collection of elements of same data type.
\n(b) Array cannot be initialised during the time of declaration.
\n(c) Array allocates continuous memory.
\n(d) An array element can be accessed using index or subscript.
\nAnswer:
\n(a) Array is a collection of elements of same data type.<\/p>\n
Question 18.
\nWhich of the following is the correct declaration of an array?
\n(a) int a(10);
\n(b) int 10[a];
\n(c) a[1] int;
\n(d) inta[10];
\nAnswer:
\n(d) int a[10];<\/p>\n
Question 19.
\nWhich is the last subscript of the array int m[25]?
\n(a) 24
\n(b) 25
\n(c) 0
\n(d) 26
\nAnswer:
\n(a) 24<\/p>\n
Question 20.
\nThe memory size of the data type float is 4 bytes. What is the total bytes required for the array declaration float salary[10];?
\n(a) 10
\n(b) 4
\n(c) 40
\n(d) 400
\nAnswer:
\n(c) 4*10 = 40.<\/p>\n
Question 21.
\nint num[100]; The above statement declares an array named num that can store maximum_____integer numbers.
\n(a) 99
\n(b) 100
\n(c) 101
\n(d) Any number
\nAnswer:
\n(b) 100<\/p>\n
Question 22.
\nIf int a[10]; is array, then which element of the array will be referenced as a[4].
\nAnswer:
\nFifth element.<\/p>\n
Question 23.
\nConsider the following array declaration int A[ ] = {4, 5, 8}; int B[ ]={2, 10};
\nWrite a valid C++ statement for finding the difference between the last element of the array \u2018B\u2019 and the first element of the array \u2018A\u2019.
\nAnswer:
\nB[1] – A[0]; ORA[0] – B[1];<\/p>\n
Question 24.
\nConsider the following code and predict the output.
\nint sum=0;
\nint a[5] = {1, 2, 3, 4, 5};
\nfor(i=0;i<4;++i)
\n{
\nsum=sum+a[i];
\n}
\ncout<<sum;
\nAnswer:
\n10.<\/p>\n
Question 25.
\nWhich data type is used to declare a variable to hold string data?
\nAnswer:
\nThe data type char is used for this.<\/p>\n
Question 26.
\nThe terminating character of string array is______
\nAnswer:
\n\\0 or NULL character.<\/p>\n
Question 27.
\nWrite a statement for storing the string \u201cNO SMOKING\u201d using a character array with name \u2018ARR\u2019
\nof minimum size.
\nAnswer:
\nchar APR[11] = \u201dNO SMOKING\u201d;<\/p>\n
Question 1.
\nGiven some array declaration. Pick the odd man out.
\nFloat a[+40], int num[0-10], double [50]. char name[50], amount[20] of float.
\nAnswer:
\nchar name[50]. It is a valid array decalaration the remaining are not valid.<\/p>\n
Question 2.
\nWhether the statement char text[] = “COMPUTER”; is True \/ False ? Justify.
\nAnswer:
\nIt is a single-dimensional array. If the user doesn’t specify the size the operating system allocates the number of characters + one (for null character for text) bytes of memory. So here OS allocates 9 bytes of memory.<\/p>\n
Question 3.
\nSuppose you are given Total mark of 50 students in a class<\/p>\n
Answer:
\nWe have to declare 50 variables individually to store total marks of 50 students. It is a laborious work. Hence we use array, it is an efficient way to declare 50 variables.<\/p>\n
With a single variable name we can store multiple elements. Eg: int mark[50]. Here we can store 50 marks. The first mark is in mark[0], second is in mark[1], …etc the fiftieth mark is in mark[49].<\/p>\n
Question 4.
\nConsider the statement charstr[ ] = “PROGRAM” What will be stored in last location of this array. Justify
\nAnswer:
\nThe last location is the null character(\\0) because each string must be appedend by a null character.<\/p>\n
Question 5.
\nExplain the needs for arrays
\nAnswer:
\nArray is collection of same type of elements. With the same name we can store more elements. The elements are distinguished by using its index or subscript. To store 50 marks of 50 students we have to declare 50 variables, it is a laborious work.<\/p>\n
Hence the need for arrays arise. By using array this is very easy as follows int mark[50]. Here the index of first element is 0, then 1, 2, 3, etc upto 49.<\/p>\n
Question 6.
\nConsider the following code and predict the output.
\nint a[5]= {6, 8, 10,20,40};
\ncout<<\u201c\\n\u201d<<a[3];
\ncout<<\u201c\\n”<<a[1]+1[4];
\nAnswer:
\n20(The fourth element).
\n48(Sum of second element 8 and fifth element 40, i.e 8 + 40 =48).<\/p>\n
Question 7.
\nSuppose you need to store the value 10, 20, 30, 40 and 50 into an array. Write different methods to do this problem. Answer:
\nMethod 1:
\nint a[5]={10, 20, 30, 40, 50};<\/p>\n
OR<\/p>\n
int a[ ]={10, 20, 30, 40, 50};<\/p>\n
Method 2:
\nint a[5];
\na[0]=10;
\na[1]=20;
\na[2]=30;
\na[3]=40;
\na[4]=50;<\/p>\n
Question 8.
\nWhat would be the appropriate array declaration to store the following?<\/p>\n
Answer:<\/p>\n
Question 9.
\nConsider the following code and predict the output.
\nint A[5] = {11, 12, 13, 14, 15};
\nint i;
\nfor (i=4;i>=0;–i)
\n{
\ncout<<\u201c\\n\u201d<<A[i];
\n}
\nAnswer:
\nIt prints the array in reverse order as follows.
\n15
\n14
\n13
\n12
\n11.<\/p>\n
Question 10.
\nPredict the output of the following code segment.
\nint K[ ] = {1, 2, 3, 4};
\nfor (int i=0; i<4; i++)
\ncout<<K[i] * K[i]<<\u201c\\t\u201d;
\nAnswer:
\nThe output is as follows
\n1 4 9 16
\nHint: 1(1*1) 4(2*2) 9(3*3) 16(4*4).<\/p>\n
Question 11.
\nConsider the following code and predict the output.
\nJustify your answer.
\nint A[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
\nint sum=0, i;
\nfor(i=0;i<10;++i)
\n{
\nif (A[i]%2==0)
\n{
\nsum=sum+A[i];
\n}
\n}
\ncout<<\u201c\\nSum=\u201d<<sum;
\nAnswer:
\nThe output is 30. That is sum of all even numbers in the array.<\/p>\n
Question 12.
\nPredict the output of the following C++ statement.
\nchar str[8] = \u201cWELCOME\u201d;
\ncout<<\u201c\\n\u2019\u2019<,str[3];
\ncout<<\u201c\\n\u201d<<str;
\nAnswer:
\nThe output is as follows
\nC(The fourth character)
\nWELCOME.<\/p>\n
Question 13.
\nHow many bytes will be allocated in the memory for storing the string \u201cMY SCHOOL\u201d? Justify your answer.
\nAnswer:
\nA total of 10 bytes. 9 bytes is used to store 9 characters in the string MY SCHOOL(including 1 byte for space) and 1 byte is used to store the NULL character.<\/p>\n
Question 1.
\nTotal mark of 50 students in a class are given in an array. A bonus of 10 marks is awarded to all of them. Write the program code for making such a modification.
\nAnswer:
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
Question 2.
\nWrite the program code for counting the number of vowels from your school name
\nAnswer:
\n# include
\n# include
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
<\/p>\n
Question 3.
\nWrite the program code for counting the number of words from the given string.” Directorate of Higher Secondary Examination”
\nAnswer:
\n# include
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
OR<\/p>\n
(Program for more than one space between words)
\n# include
\n# include
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
<\/p>\n
<\/p>\n
Question 4.
\nGiven a word like “ECNALUBMA” Write the program code for arranging it in into a meaningful word Answer:
\n# include
\n# include
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
Question 5.
\nExplain different types of arrays.
\nAnswer:
\n1. Single dimensional:
\nIt contains only one index or subscript. The index starts from 0 and ends with size-1.
\nEg. int n[50]; charname[10];<\/p>\n
2. Multidimensional: Question 6. Question 7. Question 8. Question 9. Question 10. Question 11. Question 12. Question 13. If the string entered is \u201cHAPPY NEW YEAR\u201d. Predict the output in both cases and justify your answers. Question 14. Answer:<\/p>\n 1 byte for \\n. 1 byte for \\0(The null character that is automatically appended) and 9 bytes for the remaining characters (N, 0, S, M, 0, K, l, N AND G).<\/p>\n Question 15. Question 1. <\/p>\n Question 2. Question 3. Question 4. <\/p>\n Question 5. OR<\/p>\n Write a C++ program to store the scores of 10 batsmen of a school cricket team and find the largest and smallest score. Question 6. Question 7. Kerala Plus Two Computer Application Chapter Wise Questions and Answers Chapter 2 Arrays Plus Two Computer Application Arrays One Mark Questions and Answers Question 1. From the following which is not true for an array (a) It is easy to represent and manipulate array variable (b) Array uses a compact memory structure (c) Readability of […]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[42728],"tags":[],"yoast_head":"\n
\nIt contains more than one index or subscript. The two dimensional array contains two indices, one for rows and another for columns. The row index starts from 0 and end at row size-1 and column index starts at 0 and ends at colunn size-1.
\nEg. int n[10][10] can store 10 * 10 =100 elements. The index of the first element is n[0][0] and index of the 100th<\/sup> element is n[9][9].<\/p>\n
\nWrite a program to read the 5 marks of a students and display the marks and total. Answer:
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nExplain different array operations in detail.
\nAnswer:<\/p>\n\n
\nGiven a word “COMPUTER”, write a C++ program to reverse the word without using any string functions.
\nAnswer:
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nWrite statements to declare an array and initialize it with the numbers 1, 2, 3, 4, 5 and print 5, 4, 3, 2, 1.
\nAnswer:
\n# include
\nusing namespace std;
\nint main()
\nint a[5]={1, 2, 3, 4, 5},i;
\nfor(i=4;i>=0;i-)
\ncout<<a[i]<<\u201c,\u201d;
\n}<\/p>\n
\nConsider the following array declaration. Write statements to count how many numbers are greater than zero.
\nint p[ ] = {-5, 6, -7, 0, 8, 9};
\nAnswer:
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nWrite a C++ program to read 10 integer values and find the largest number among them using array.
\nAnswer:
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nWrite a C++ program to accept a string from the keyboard and find its length without using function. For example if \u201cWELCOME\u201d is accepted, the output will be 7.
\nAnswer:
\n# include
\n# include
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nConsiderthe following C++ statements<\/p>\n\n
\ncin>>word;
\ncout<<word;<\/li>\n
\ngets(word);
\nputs(word);<\/li>\n<\/ol>\n
\nAnswer:<\/p>\n\n
\nConsider the following C++ statements
\nchar str[] = \u201cNO\/nSMOKING\u201d;
\ncout<<str;<\/p>\n\n
\n
\nSMOKING. The output is in 2 lines.<\/li>\n
\nWrite a C++ program to store the given string in an array and display it in reverse order without using string function. For example if ABCD is given, the output should be DCBA.
\nAnswer:
\n# include
\n#include
\nusing namespace std;
\nint main()
\n<\/p>\nPlus Two Computer Application Arrays Five Mark Questions and Answers<\/h3>\n
\nCollect the heights of 12 students from your class in which 7 students are male and others are female students. Suppose these male and female students be seated in two separate benches and you are given a place which is used for sitting these 12 students in linear form. How will you combine and make them sit without mixing male\/female students? Write a program for the same.
\nAnswer:
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nWrite a program to read 3 marks of 5 students and find the total and display it
\nAnswer:
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nWrite a program to read a string and a character and find the character by using linear search.
\nAnswer:
\n# include
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nWrite a program to read a string and find the no. of vowels consonents and special characters.
\nAnswer:
\n# include
\n#include
\n#include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nWrite a program to accept marks of 10 students and find out the largest and smallest mark from the list.<\/p>\n
\nAnswer:
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nWrite a C++ program to read 6 marks of a student and find total and average mark.
\nAnswer:
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\n
\nWrite a C++ proram to accept a sentence and count the number of times the letter ‘s\u2019 occurs in it. For example if the sentence is This is my school\u2019, the output should be 3.
\nAnswer:
\n# include
\n# include
\nusing namespace std;
\nint main()
\n<\/p>\nPlus Two Computer Application Chapter Wise Questions and Answers<\/a><\/h4>\n","protected":false},"excerpt":{"rendered":"