Class 10 Computer Science Chapter 5 | Arrays in C Question Answer: Welcome to our website! We are happy to provide you with Class 10th Notes for your academic journey. Class IX is an essential year for learners as they prepare themselves for the upcoming board exams, which will determine their academic success.
Today, I will discuss your Class 10th “Arrays in C” Long and Short Questions| We provide solutions for almost all long and short questions.
Our goal is to meet your needs. We provide the Notes here for free. We wish you all the best for your upcoming exams. If you have any doubts, don’t hesitate to get in touch with us.
Arrays in C Question Answer
TEXTUAL QUESTIONS AND ANSWERS:
EXERCISE
1. Define array. Why do we use arrays in computer programs?
Ans. Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.
For example, if you want to store 10 integers, you can create an array for it.
int data[10];
Arrays are used to store multiple values of the same data type.
For example,
int a;
In the above, variable a can store only one value of only integer type. But in an array, if we declare variable an as integer, then we can store n number of integer type of value where n is the index of the array.
int a[10];
In the above, we can store 10 integer values in the variable a.
2. Can we store both integer and float types of data in a single array? Demonstrate this with a C
Ans. If we declare an array as an integer we can store the values of integer type only not of character or float type. So, we cannot store both integer and float types in a single array.
For example, if we want to declare an array of integer and float type, then we have to declare two variables with different data types as follows:
int a[10];
float b[10];
3. Write the indices of the first and last element of the following array declaration.
char city [7] = {‘S’, ‘T’, ‘L’, ‘C’, ‘H’, ‘A’, ‘R’};
Ans. Indices of the first element of the array is O.
Indices of the last element of the array is 6
4. Write a C program and declare an integer type array with capacity 7. Take input to the array from the keyboard. Display the 7th element of the array.
Solution:
Code:
#include<stdio.h>
int main()
{
int a[7], i;
printf(“Enter the values of array: “);
for(i=0; i<7;i++)
{
scanf(“%d”, &a[i]);
}
printf(“The 7th element is %d”, a[6]);
return 0;
Output:
Enter the values of array : 6
5
3
2
1
8
9
The 7th element is 9
Process returned 0 (0x0) execution time: 5.486 S
Press any key to continue.
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.
Solution:
Code:
Conclusion:
We believe these notes will help learners better understand the topics and boost their confidence for their exams.We are confident these notes will help learners achieve their goals and enhance their academic performance. If you like this article and find it helpful, please share it with your friends.