Quiz for C (Arrays)
Q.1. What is an Array in C language ?
Q.2. How array is initialized in C ?
Q.3. What is the maximum size of an array in c ?
Q.4. An array elements are always stored in ______ memory location?
Q.5. An array is a group of memory locations related by the fact that
they all have the same name and the same type.
Q.6. An array Index starts with ?
Q.7. What will be printed after execution ?
#include <stdio.h>
void main()
{
int a[10] = {1,2,3,4,5};
printf("%d",a[5]);
}
Q.8. Which of the following are true ?
1. The array int num[26]; can store 26 elements.
2. The expression num[1] designates the very first element in the array.
3. It is necessary to initialize the array at the time of declaration.
4. The declaration num[SIZE] is allowed if SIZE is a macro.
1. The array int num[26]; can store 26 elements.
2. The expression num[1] designates the very first element in the array.
3. It is necessary to initialize the array at the time of declaration.
4. The declaration num[SIZE] is allowed if SIZE is a macro.
Q.9. How to declare a 2D and 3D array in C?
Q.10. What is the output of C program?
#include <stdio.h>
int main()
{
float marks[3] = {90.5, 92.5, 96.5};
int a=0;
while(a<3)
{
printf("%.2f,", marks[a]);
a++;
}
}
Q.11. What is the output of C program ?
int main()
{
int a[3] = {10,12,14};
int i=0;
while(i<3)
{
printf("%d ", i[a]);
i++;
}
}
Q.12. Which of the following is correct way to access 8th element from
an array with 100 element (arr[100]) ?
Q.13. What is meaning of following declaration ?
int(*ptr)[10];
int(*ptr)[10];
Q.14. What is the output of C program ?
#include <stdio.h>
void main()
{
int a[5] = {1,2,3,4,5};
int b = sizeof(a)/sizeof(a[0]);
printf("%d" , b);
}
Q.15. Predict the output of C program with arrays and pointers?
#include<stdio.h>
int main()
{
int a[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
int i,j;
int x=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
x +=a[i][j];
}
}
printf("%d",x);
}
Q.16. Predict the output of C program with arrays and pointers?
int main()
{
int a[3] = {20,30,40};
int *p[3];
p=&a;
printf("%d", *p[2]);
}
Q.17. What is the output of C program with arrays and pointers?
int main()
{
int a[4] = {5,6,7,8};
int i;
int n = sizeof(a)/sizeof(a[3]);
for(i=n-1;i>=0;i--)
{
printf("%d",a[i]);
}
}
Q.18. An entire array is always passed by ___ to a called function.
Q.19. Guess the output of C Program with arrays and pointers ?
void change(int[]);
int main()
{
int a[3] = {20,30,40};
change(a);
printf("%d %d", *a, a[0]);
}
void change(int a[])
{
a[0] = 10;
}
Q.20. Guess the output of C Program with arrays and pointers ?
int main()
{
int a[2] = {11};
printf("%d",1[a]);
return 0;
}
Instructions:-
- This Quiz is based on the concepts of Arrays in C
- Each correct answer will carry 2 points
- Once an option is selected you cannot select any other, So choose wisely
- Do not refresh the page as it will reset the quiz
- Once the time is up the quiz will automatically get submitted with no of Question responded
- Your total score alongwith your name will be shown after submission of the Quiz
- Wish you ALL THE BEST 👍👍
START
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP