Menu Close

C exam on Arrays

Please enter your email:

1.

Output of following C program?

#include<stdio.h>
void test(int, int);
int main ()
{
  int a[5]={4,2,3,5,6},i,s=0;
  test(a[3], a[1]);
  for(i=0; i<5 ; i++)
    s=s+a[i];
  printf("%d ",s);
  return 0;
}
void test(int x, int y)
{
  ++x;
  --y;
}

 

 
 
 
 

2.

What Array variable holds?

 
 
 
 

3.

Output of following C program?

#include<stdio.h>
int main()
{
  int a[5], i=1;
  while(i<5)
    a[i] = i++ + 2;

  for(i=1; i<5; i++)
    printf("%d ", a[i]);
  return 0;
}

 

 
 
 
 

4.

Output of following C program?

#include<stdio.h>
int main ()
{
  int x[5]={9,2,7,6,5}, i, s=0;
  for(i=0 ; i<5 ; i++)
    x[i]=x[i]+i;
  for(i=1 ; i<4 ; i++)
    s+=x[i];
  printf("%d ", s);
  return 0;
}

 

 
 
 
 

5.

Output of following C program?

#include<stdio.h>
int main()
{
  int a[6]={3,8,2,9,1,7}, i, j=3;
  for(i=0 ; i<6 ; i++)
  {
    j=a[++i] + --j ; 	
  }
  printf("%d ", j);
  return 0;
}

 

 
 
 
 

6.

Output of following C program?

#include<stdio.h>
int main()
{
  int k=1, n[5], i, sum=0;
  for(i=0 ; i<5 ; i++ )
  {
    sum = i + ++k;
    n[i] = sum + ++k;
  }
  printf("%d ",n[4]);
}

 

 
 
 
 

7.

Output of following C program?

#include<stdio.h>
int main ()
{
  short int a[4];
  printf("%d ",sizeof(a));
  printf("%d ",sizeof(a[0]));
  printf("%d ",sizeof(a)/sizeof(a[0]));
  return 0;
}

 

 
 
 
 

8.

Passing array as an argument to a function nothing but ________

 
 
 
 

9.

Output of following C program?

#include<stdio.h>
int main ()
{
  int a[] = {7,3,2,1};
  printf("%d ",sizeof(a));
  return 0;
}

 

 
 
 
 

10.

The elements in the array of the following code are int array[5] = {5};

 
 
 
 

Question 1 of 10