C Array Questions and Answers
Practice ModeShowing 10 of 108 questions
Q31
Which of the following operation is legal with array a[5]?
Answer: Option B
Q32
Find the output
void main ()
{
int array [ ] ={1, 3, 5, 7, 9}, *p, i;
p=array [0];
for (i=0; i<5; i++)
printf("%2d", ++*p);
}
Answer: Option D
Q33
This is a small program to find the maximum element in an array. How many comparisons in the below function to find the maximum element.
int findmax (int A[ ], int n)
{
int max, i;
max=A[0];
for (i=1; i<n; i++)
if (A[i] >max)
max =A[i];
return max ;
}
Answer: Option A
Q34
Find the output
void main ( )
int a[5];
a[-2]=5;
a[2]=1;
printf("%d", -2[a]);
}
Answer: Option B
Q35
Find the output
void main ()
[
int a[ ] ={1, 2, 3, 4, 5}, *p,*q;
p=a;
q=a;
if (*p++==++*q)
printf("Equal");
else
printf("Not equal");
}
Answer: Option A
Q36
Find the output
void main ()
{
int *p, a[5]={1, 2, 3, 4, 5}
p=a;
printf("%d %d %d", ++*p, ++*p);
}
Answer: Option C
Q37
Find the output
void main( )
{
int a[]={{1+2}, {3+4}, {5+6}}, i;
for (i=0; i<3; i++)
printf("%2d",a[1]);
}
Answer: Option A
Q38
Find the output
int arr [ ]={1, 2, 3};
void main ( )
{
int a, *p, b, c;
a=51 %26;
p=&a;
a+=2;
b=arrr[1]+a;
c=*p+b;
printf("%d %d %d", a, b, c);
}
Answer: Option D
Q39
Find the output
void main ( )
{
int a[ ]={0, 0, 0, 0, 0, }, *p, i;
p=a;
for (i=0; i<5; i++)
printf("%2d", ++*p+a [i]);
}
Answer: Option B
Q40
Find the output
void main ( )
{
int a [ ] [4]= {1, 2, 3, 4, 5, 6, 7, 8};
int (*p) [4]=a;
printf("%d %d", (*p+1)[1], (*p) [2]);
p++;
printf("%d %d", (*%d %d", (*p+2) [0], (*p)[2]);
}
Answer: Option D