Class 10 Computer Science Chapter 6 Question Answer

“Explore comprehensive question and answer solutions for Class 10 Computer Science Chapter 6. Enhance your understanding with detailed explanations and step-by-step guidance for all key topics covered in the chapter.”

1. Define array. Why do we use arrays in computer programs?

Ans: An array is a data structure that can hold multiple values of the same type in a single variable. Arrays allow programmers to store and manipulate data collection in an organized manner. We use arrays in computer programs to efficiently manage and process large sets of related data, enabling easy access and modification through indexing.

2. Can we store both integer and float types of data in a single array? Demonstrate this by writing a simple C program.

Ans: No, we cannot store both integer and float types of data in a single array as arrays in C are homogenous, meaning all elements in an array must be of the same data type.

Example: 

3. Write the indices of the first and last element of the following array declaration.

The given array is char city[7] = {‘S’, ‘T’, ‘L’, ‘C’, ‘H’, ‘A’, ‘R’};.

The index of the first element (‘S’) is 0.

The index of the last element (‘R’) is 6.

4. Write a C program and declare an integer type array with a capacity of 7. Take input to the array from the keyboard. Display the 8th element of the array. Hint: display num[7] if num is the name of the array. Analyze the output.

Ans:

Analysis: The array num has a capacity of 7, so accessing num[7] will go out of bounds, leading to undefined behavior. The program may display a garbage value or cause a runtime error.

5. Write a C program and declare an integer-type array with 7 elements in it. Display the address of the individual elements in the array.

Ans:

6. Write a C program and declare two integer type arrays, each with a capacity of 7. Take input only to the first array. Write a loop to copy the elements of the first array to the second one. Display the elements of the second array.

Ans:

7. Write a strategy to find the summation of all the even numbers stored in an array. Write a C program for the same. If the array elements are {1, 2, 4, 3, 5, 6, 7, 8}, the output of the program will be 20.

Ans:

8. Write a strategy to find the summation of all the even positioned numbers stored in an array. Write a C program for the same. If the array elements are {1, 2, 4, 3, 5, 6, 7, 8}, the output of the program will be 18.

Ans:

9. Write the logic to replace only the first occurrence of an element in an array. For example, if the array elements are {1, 2, 3, 4, 5, 1, 2, 3} and we want to replace element 3 by 0, the array content becomes {1, 2, 0, 4, 5, 1, 2, 3}. Write a complete C program incorporating the logic.

Ans:

10. Write the logic to replace only the last occurrence of an element in an array. For example, if the array elements are {1, 2, 3, 4, 5, 1, 2, 3} and we want to replace element 3 by 0, the array content becomes {1, 2, 3, 4, 5, 1, 2, 0}. Write a complete C program incorporating the logic.

Ans:

11. Write a C program to replace all the even-positioned elements in an integer array by 0.

Ans:

12. Write a strategy to replace all the odd numbers in an integer array by 0.

Ans:

13. Write a C program to store your name and your mother’s name in two different strings. Display them one after another.

Ans:

14. Write a C program to declare 3 integer type arrays to store the marks of 10 students scored in 3 different subjects. Take another integer to store the average marks of the students. The program should display the average marks of the students and whether they “PASS” (average >= 45) or “FAIL”.

Ans:

15. Write any two limitations of arrays. Can you store your name and roll number in the same array?

Ans: Limitations of Arrays:

Fixed Size: Once an array is declared, its size cannot be changed. This can lead to either wastage of memory if the array size is too large or lack of sufficient memory if the array size is too small.

Homogeneous Data: Arrays can store only elements of the same data type. You cannot store different data types in a single array.

Can You Store Your Name and Roll Number in the Same Array?

Ans: No, you cannot store both your name (which is a string) and your roll number (which is an integer) in the same array because arrays in C are homogeneous, meaning they can only store elements of the same data type.

Leave a Comment