C-Array Questions and Answers

C-Array Questions and Answers
31. Which of the following operation is legal with array a[5]?
  • a++
  • a+1
  • ++a
  • a*2
Show Answer
32. 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);
}

  • 2 3 4 5 6
  • 1 3 5 7 9
  • 1 2 3 4 5
  • 1 2 3 4 5 Null pointer assignment
Show Answer
33. 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 ;
}

  • n-1
  • n+1
  • n/2
  • n
Show Answer
34. Find the output
void main ( )
int a[5];
a[-2]=5;
a[2]=1;
printf("%d", -2[a]);
}

  • 5
  • -1
  • Memory dump
  • None of these
Show Answer
35. 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");
}

  • Equal
  • Not equal
  • Compilation error
  • None of these
Show Answer
36. Find the output
void main ()
{
int *p, a[5]={1, 2, 3, 4, 5}
p=a;
printf("%d %d %d", ++*p, ++*p);
}

  • 1 2 3
  • 3 2 1
  • 3 3 2
  • None of these
Show Answer
37. Find the output
void main( )
{
int a[]={{1+2}, {3+4}, {5+6}}, i;
for (i=0; i<3; i++)
printf("%2d",a[1]);
}

  • 3 7 11
  • 2 4 6
  • 1 3 5
  • Compilation error
Show Answer
38. 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);
}

  • 25 27 52
  • 27 29 54
  • 27 28 53
  • 27 29 56
Show Answer
39. 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]);
}

  • 1 2 3 4 5
  • 2 2 3 4 5
  • 1 1 1 1 1
  • None of these
Show Answer
40. 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]);
}

  • 2356
  • 2256
  • 3366
  • 3377
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test