Looking for accurate SEBA Class 10 Computer Science Chapter 6 (Arrays in C) textual solutions for the 2026–27 academic year? Access step-by-step textbook exercise answers, 1D and 2D array declarations, array initialization logic, indexing concepts, and full C code solutions designed to help you score top marks in your HSLC board exams.
1. Define array. Why do we use arrays in computer programs?
Answer: An array in C is a group of similar data items stored together in memory. It has a fixed size and lets you manage large amounts of data using one name instead of many variables. To create an array, mention the data type (like int) and the array name followed by square brackets []. You can add values using a comma-separated list inside curly braces {}.
Example:
int a[] = {25, 50, 75, 100};
2. Can we store both integer and float types of data in a single array? Demonstrate this by writing a simple C program.
Answer: No, we cannot store both integers and floating-point numbers in the same array because a C array can only hold items of one single data type.
If we want to group different types of data together, we can use a struct (Structure). A structure lets us bundle different data types (like int and float) into one package.
#include<stdio.h>
struct Data
{
int num;
float decimal;
};
int main()
{
struct Data arr[2];
arr[0].num = 10;
arr[0].decimal = 3.14;
printf("Integer: %d\n", arr[0].num);
printf("Float: %.2f\n", arr[0].decimal);
return 0;
}
3. Write the indices of the first and last element of the following array declaration. char city [7]={‘S’, ‘I’, ‘L’, ‘C’, ‘H’, ‘A’, ‘R’, };
Answer: Indices of the first element of the array is 0.
Indices of the last element of the array is 6
SEBA Class 10 Computer Science Chapter 6 Solutions
4. Write a C program and declare an integer type array with capacity 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.
Answer: #include<stdio.h>
int main()
{
int a[7];
int i;
printf(“Enter 7 integers, one at a time:\n”);
for (i = 0; i < 7; i++)
{
scanf(“%d”, &a[i]);
}
printf(“The 7th element is: %d\n”, array[6]);
return 0;
}
Output Example:
Enter 7 integers, one at a time:
10
20
30
40
50
60
70
The 7th element is: 70
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.
Answer: #include<stdio.h>
int main()
{
int a[7], i;
printf("Enter seven elements:\n");
for (i = 0; i < 7; i++) {
scanf("%d", &a[i]);
}
printf("\nAddresses of elements:\n");
for (i = 0; i < 7; i++) {
printf("Element %d Address: %p\n", i, (void*)&a[i]);
}
return 0;
}
Enter seven elements:
10 20 30 40 50 60 70
Addresses of elements:
Element 0 Address: 0x7ffe6a9d19d0
Element 1 Address: 0x7ffe6a9d19d4
Element 2 Address: 0x7ffe6a9d19d8
Element 3 Address: 0x7ffe6a9d19dc
Element 4 Address: 0x7ffe6a9d19e0
Element 5 Address: 0x7ffe6a9d19e4
Element 6 Address: 0x7ffe6a9d19e8
6. Write a C program and declare two integer type arrays, each with capacity 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.
Answer: #include<stdio.h>
int main()
{
int a[7], b[7], i;
printf(“Enter 7 numbers for the first array: “);
for (i = 0; i < 7; i++)
{
scanf(“%d”, &a[i]);
}
for (i = 0; i < 7; i++)
{
b[i] = a[i];
}
printf(“\nSecond array elements are:\n”);
for (i = 0; i < 7; i++)
{
printf(“%d\t”, b[i]);
}
return 0;
}
Output Example:
Enter 7 numbers for the first array: 10 20 30 40 50 60 70
Second array elements are:
10 20 30 40 50 60 70
Class 10 Computer Science Chapter 6 Question Answer SEBA 2026-27
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, 7, 8}, the output of the program will be 20.
Answer: Strategy:
- Create an integer array to store numbers.
- Start with a variable sum set to 0.
- Use a loop to go through each element of the array.
- Check if each number is even using number % 2 == 0.
- If the number is even, add it to sum.
- Repeat this for all numbers in the array.
- After the loop ends, sum will contain the total of all even numbers.
C Program
#include<stdio.h>
int main()
{
int arr[9] = {1, 2, 4, 3, 5, 6, 7, 7, 8};
int sum = 0, i;
for (i = 0; i < 9; i++)
{
if (arr[i] % 2 == 0)
{
sum += arr[i];
}
}
printf("Sum = %d\n", sum);
return 0;
}
Output
Sum = 20
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, 7, 8}, the output of the program will be 18.
Answer: Strategy:
Create an integer array to store the numbers.
Start with a variable sum set to 0.
Use a loop to iterate through the array, beginning at the second element (index 1).
Add each number at an even position (index 1, 3, 5, etc.) to sum.
Continue until all even-positioned elements are processed.
The variable sum will then have the total of all even-positioned numbers.
C Program:
#include<stdio.h>
int main()
{
int a[] = {3, 6, 9, 12, 15, 18, 21};
int n = sizeof(a) / sizeof(a[0]);
int sum = 0;
for (int i = 1; i < n; i += 2)
{
sum = sum + a[i];
}
printf(“The summation of even-positioned numbers in the array is: %d\n”, sum);
return 0;
}
Arrays in C Class 10 SEBA Textual Exercise Solutions
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.
Answer: Logic
- Create an integer array to store the numbers.
- Define the element you want to replace and the value to replace it with .
- Use a loop to go through the array.
- When the first occurrence of the element to replace is found, change it to the replacement value.
- Exit the loop immediately after the replacement.
- Print the updated array.
C Program:
#include<stdio.h>
int main()
{
int a[] = {1, 2, 3, 4, 5, 1, 2, 3};
int n = sizeof(a) / sizeof(a[0]);
int x = 3;
int z = 0;
int i;
for (i = 0; i < n; i++)
{
if (a[i] == x)
{
a[i] = z;
break;
}
}
printf(“Updated array: “);
for (i = 0; i < n; i++)
{
printf(“%d “, array[i]);
}
printf(“\n”);
return 0;
}
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.
Answer: Logic:
- Create an array to store the numbers.
- Prompt the user to input the number they want to replace.
- Loop through the array to find the last 4. occurrence of the number to replace.
- Once found, replace that last occurrence with the new value (e.g., 0).
- Display the updated array.
C Program:
#include<stdio.h>
int main()
{
int a[7], i, x;
printf(“Enter the values of the array: “);
for (i = 0; i < 7; i++)
{
scanf(“%d”, &a[i]);
}
printf(“\nEnter the number to be replaced: “);
scanf(“%d”, &x);
for (i = 7; i > 0; i++)
{
if (a[i] == x)
{
a[i]=x;
}
}
printf("\nUpdated array after replacing the last occurrence: \n");
for (i = 0; i < 7; i++)
{
printf(“%d “, a[i]);
}
return 0;
}
11. Write a C program to replace all the even positioned elements in an integer array by 0. For example, if the array elements are {1, 2, 3, 9, 5, 5, 7, 1, 9}, it becomes
{1, 0, 3, 0, 5, 0, 7, 0, 9}.
Logic:
- Create an integer array with the given elements.
- Loop through the array, starting from the second element (index 1).
- Replace every element at an even position (index 1, 3, 5, etc.) with 0.
- Print the updated array.
C Program:
#include<stdio.h>
int main()
{
int a[] = {1, 2, 3, 9, 5, 7, 1, 9};
for (int i = 1; i < 8; i += 2)
{
a[i] = 0;
}
printf("Updated array: ");
for (int i = 0; i < n; i++)
{
printf("%d ", array[i]);
}
printf("\n");
return 0;
}
Example Output:
Updated array: 1 0 3 0 5 0 7 0 9
SEBA Class 10 Computer Science Chapter 6 Programs
12. Write a strategy to replace all the odd numbers in an integer array by 0. For example, if the array elements are {1, 2, 3, 9, 5, 5, 7, 1, 9}, it becomes {0, 2, 0, 0, 0, 0, 0, 0, 0}. Write a C program for the same.
Strategy for Replacing Odd Numbers:
- Declare an integer array with some initial values.
- Use a loop to iterate through each element of the array.
- If the number is odd (i.e.,
number % 2 != 0), replace it with 0. - Continue this process for all elements of the array.
- Print the updated array.
C Program for Replacing Odd Numbers:
#include <stdio.h>
int main()
{
int a[] = {1, 2, 3, 9, 5, 5, 7, 1, 9};
for (int i = 0; i < 9; i++)
{
if (a[i] % 2 != 0)
{
a[i] = 0;
}
}
printf("Updated array: ");
for (int i = 0; i < 9; i++)
{
printf("%d ", a[i]);
}
printf("\n");
return 0;
}
Example Output:
Updated array: 0 2 0 0 0 0 0 0 0
13. Write a C program to store your name and your mother’s name in two different strings. Display them one after another.
#include<stdio.h>
#include<string.h>
int main()
{
char Your_name[20],Mother_name[20];
printf("\n Enter your name: ");
gets(Your_name);
printf("\n Enter your mother name: ");
gets(Mother_name);
printf("\n Your name is: ");
puts(Your_name);
printf("\n Your mother name is: ");
puts(Mother_name);
return 0;
}
Example Output:
Enter your name: Asgar
Enter your mother name: Hamida
Your name is: Asgar
Your mother name is: Hamida
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 average mark of a student is the average of the marks scored by the student in 3 subjects. This should be calculated and inserted by the program. Then you should display the average marks of the students. The program should also display “PASS” or “FAIL” along with the average as per the rule: PASS if average >= 45, FAIL otherwise.
15. Write any two limitations of arrays. Can you store your name and roll number in the same aray?
Limitations of Arrays:
- The size of an array is fixed, so you cannot add or remove elements once it is created.
- Arrays can only store elements of the same data type. You cannot store different types of data (like integers and characters) in the same array.
No, we cannot store both name and roll number in the same array because they are of different data types. A character array can only store characters, while a roll number is an integer.
HSLC Computer Science Arrays in C Question Answer
💻 Updated Solutions Notice: This page features complete, step-by-step SEBA Class 10 Computer Science Chapter 6 (Arrays in C) Textual Exercise Solutions updated for the 2026–27 academic session. All array indexing rules, memory allocation concepts, and C programming codes strictly follow the latest revised Assam Board (SEBA) textbook.
💡 Ace Your HSLC Computer Science Exam:
- Have a doubt about 1D vs 2D arrays, array bounds, zero-based indexing, or array traversal in C? Drop your query in the comments section below!
- Save and bookmark this solution guide for quick reference before your unit tests, half-yearly, and pre-board examinations.
- Share this link with your classmates and WhatsApp study groups to help them master C programming concepts!