Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.

C Programming :: Arrays

Home > C Programming > Arrays > General Questions

21. What will be output of the following "c" code?

#include
#define DIM( array, type) sizeof(array)/sizeof(type)
void main()
{
int arr[10];
printf("dimension of the array is %d", DIM(arr, int));
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

The size of integer array of 10 elements is 10 * sizeof(int). The macro expands to sizeof(arr)/sizeof(int) => 10 * sizeof(int) / sizeof(int) => 10.

Workspace

Tags:

No Tags on this question yet!

22. What will be output of the following "c" code?

#include
int DIM(int array[])
{
return sizeof(array)/sizeof(int );
}
void main()
{
int arr[10];
printf("The dimension of the array is %d", DIM(arr));
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Arrays cannot be passed to functions as arguments and only its base address passed. So the argument is equivalent to int * array (this is one of the very few places where [] and * usage are equivalent). The return statement becomes, sizeof(int *)/ sizeof(int) that happens to be equal in this case.

Workspace

Tags:

No Tags on this question yet!

23. What will be output of the following "c" code?

#include
void main()
{
static int a[3][3]={1,2,3,4,5,6,7,8,9};
int i,j;
static int *p[]={a,a+1,a+2};
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf("%d\t%d\t%d\t%d\n",*(*(p+i)+j),*(*(j+p)+i),*(*(i+p)+j),*(*(p+j)+i));
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

24. What will be output of the following "c" code?

#include
void main()
{
int i=10, j=2;
int *ip= &i, *jp = &j;
int k = *ip;
printf("%d",k);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

25. What will be output of the following "c" code?

#include
void main()
{
char a[4]="HELLO";
printf("%s",a);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

The array a is of size 4 but the string constant requires 6 bytes to get stored.

Workspace

Tags:

No Tags on this question yet!

26. What will be output of the following "c" code?

#include
void main()
{
char a[4]="HELL";
printf("%s",a);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

The character array has the memory just enough to hold the string "HELL" and doesn't have enough space to store the terminating null character. So it prints the HELL correctly and continues to print garbage values till it
accidentally comes across a NULL character.

Workspace

Tags:

No Tags on this question yet!

27. What is the output of the following 'C' program ?

#include
#define TOTAL_ELEMENTS sizeof(array)/sizeof (array[0])

int array[] = {23,34,12,17,204,99,16};
int main()
{
int d;
for(d = 0; d <= TOTAL_ELEMENTS; d++)
printf("%d ",array[d]);
return 0;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

28. What is the output of the following 'C' program ?

#include
#define MAX 3
int main()
{
int low[MAX];
int index;
int *high[3];
for(index = 0; index < MAX; index++)
high[index] = low + index;

for(index = 0; index < MAX; index++)
printf("%p ",high[index]);
return 0;
}
// when base address of low is 100

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

29. Arrays can be initialized provided they are

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

30. Which of the following statements is true after execution of the program

int a[l0],i,*p;
a[0]=1;
a[1]=2;
p=a;
(*p)++;

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!