Welcome Guest | Sign in | Register

Home > C Programming > Arrays > Questions and Answers

01. What value does testarray[2][1][0] in the sample code below contain?
A. 11 B. 7
C. 5 D. 9

Answer and Explanation

Answer: 11

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. What will be output when you will execute following C code?

char *someFun1()
{
char temp[ ] = “string";
return temp;
}
main()
{
puts(someFun1());
}
A. 6 B. string
C. Garbage values D. None of these

Answer and Explanation

Answer: Garbage values

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03. What will be output when you will execute following C code?

main()
{
register i=5;
char j[]= "hello";
printf("%s %d",j,i);
}
A. hello 5 B. 5 hello
C. 5 D. hello

Answer and Explanation

Answer: hello 5

Explanation:
If you declare i as register , compiler will treat it as ordinary integer and it will take integer value. i value may be stored either in register or in memory.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. What will be output when you will execute following C code?
aaa()
{
printf("hi");
}
bbb(){
printf("hello");
}
ccc(){
printf("bye");
}
main()
{
int (*ptr[3])();
ptr[0]=aaa;
ptr[1]=bbb;
ptr[2]=ccc;
ptr[2]();
}
A. hi hello bye B. bye
C. hi D. None of these

Answer and Explanation

Answer: bye

Explanation:
ptr is array of pointers to functions of return type int.ptr[0] is assigned to address of the function aaa. Similarly ptr[1] and ptr[2] for bbb and ccc respectively. ptr[2]() is in effect of writing ccc(), since ptr[2] points to ccc.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
05. What will be output when you will execute following C code?
void main()
{
int i;
char a[]="\0";
if(printf("%s\n",a))
printf("Ok here \n");
else
printf("Forget it\n");
}
A. Compilation error B. Ok here
Forget it
C. Forget it D. Ok here

Answer and Explanation

Answer: Ok here

Explanation:
Printf will return how many characters does it print. Hence printing a null character returns 1 which makes the if statement true, thus "Ok here" is printed.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
06. What will be the output of the following program if the base address of array is 100.
main()
{
int gyan[] = { 1,2,3,4,5 };
int i,*ptr ;
ptr = gyan;
for(i = 0; i<=4 ; i++)
{
printf("\n %d", *ptr++);
}
}
A. 1 2 3 4 5 B. 1 2 3 4
C. 1 2 3 D. None of these

Answer and Explanation

Answer: 1 2 3 4 5

Explanation:
ptr contains the base address of the array and printf() is printing the value at the current address contained by ptr and then incrementing the pointer to point to the next array element address.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
07. What will be output when you will execute following C code?
#include
{
char arr[11]="The African Queen";
printf("%s", arr);
return 0;
}
A. T B. Compilation error
C. The African Queen D. null

Answer and Explanation

Answer: Compilation error

Explanation:
Size of any character array cannot be less than the number of characters in any string which it has assigned. Size of an array can be equal (excluding null character) or greater than but never less than

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
08. Which of the following correctly declares an array?
A. int anarray[10]; B. int anarray;
C. anarray{10}; D. array anarray[10];

Answer and Explanation

Answer: int anarray[10];

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
09. What is the index number of the last element of an array with 29 elements?
A. 29 B. 28
C. 0 D. Programmer-defined

Answer and Explanation

Answer: 28

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
10. Which of the following is a two-dimensional array?
A. array anarray[20][20]; B. int anarray[20][20];
C. int array[20, 20]; D. char array[20];

Answer and Explanation

Answer: int anarray[20][20];

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.