Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/articles/c-tutorials/)
-   -   100 Multiple choice questions in C (http://www.go4expert.com/articles/100-multiple-choice-questions-c-t1373/)

shabbir 6Sep2007 15:18

Re: 100 Multiple choice questions in C
 
Please take the time to post the questions and if anything is not relating to the article post them as separate query in the forum.

sudheer157 6Sep2007 17:53

Re: 100 Multiple choice questions in C
 
hi shabbir
i have only scanned copies of the questions,that is the reason i send them as bmp images in zip file,if possible please send the answers to those questions,

shabbir 6Sep2007 18:00

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by sudheer157
hi shabbir
i have only scanned copies of the questions,that is the reason i send them as bmp images in zip file,if possible please send the answers to those questions,

I have deleted them and if they are not the question relating to the article have them as separate thread. Also try to type them out or try making them OCR.

sudheer157 6Sep2007 19:55

Re: 100 Multiple choice questions in C
 
hi
for Q19 in discussons you told sol is 1,but sol 3 seems to be correct,as memory created by alloca is valid only in the array_dup() function.

shabbir 6Sep2007 21:06

Re: 100 Multiple choice questions in C
 
But its non standard option forced me to opt for the other one.

DaWei 6Sep2007 21:22

Re: 100 Multiple choice questions in C
 
Not all the answers are correct. Perhaps you should expend some additional effort before publishing misleading or inaccurate information.

shigatsu 16Sep2007 12:29

Re: 100 Multiple choice questions in C
 
hi there, does anyone have answer key? i wanna know if my answers were correct. pls send me if it is ok. crazyfunk69@yahoo.com i really do appreciate it. tnx :)

Pruthvik_Falcon 22Oct2007 11:49

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by shabbir
That would be the spoiler.

Hai.............
This pruthvik here.............. i saw the questions out here it was real good fealing ......... was on some project n needed some good questions n got those but very much inneed of answers .......... plz help me out........ its damme urgent.............

Pruthvik_Falcon 22Oct2007 11:54

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by Dark_Knight
Thanks!!

can i know the answwers for those c questions........... asps

shabbir 22Oct2007 17:18

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by Pruthvik_Falcon
can i know the answwers for those c questions........... asps

Do not make the same post over and over again.

iarneel 19Nov2007 13:59

Re: 100 Multiple choice questions in C
 
plz can some1 send me the ans to/
irnish@yahoo.it

vipul_tilak 25Dec2007 19:12

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by shabbir
I would suggest dont keep them here because that would be the spoiler. Put them in a seperate thread and place a link from here if you wish to.


Hi can you please tell me the answers for the following questions?
5
6
7
8
15
16
34
36
37
42
59
61
62
75
78
80
82
85
87
90
95

Please its urgent dude.

Please help me with the answers.......

Big Thanks in advance

vipul_tilak 25Dec2007 19:14

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by vipul_tilak
Hi can you please tell me the answers for the following questions?
5
6
7
8
15
16
34
36
37
42
59
61
62
75
78
80
82
85
87
90
95

Please its urgent dude.

Please help me with the answers.......

Big Thanks in advance

My email id is vipul_tilak@yahoo.com or vipul.tilak@gmail.com

fundooboy 8Mar2008 16:06

Re: 100 Multiple choice questions in C
 
Can anyone plz send me answers at
kshire@gmail.com

michaelqiao 9Mar2008 14:51

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by fundooboy
Can anyone plz send me answers at
kshire@gmail.com

can anyone please send me the answers to my email michaelqiao59@gmail.com?

intelaravind 15Apr2008 19:52

Re: 100 Multiple choice questions in C
 
:crazy: :crazy: can any one pls mail the answers of all questions to intelaravind@gmail.com.
:D and if possible with explanation

MultipleChoiceInC 6May2008 04:52

Re: 100 Multiple choice questions in C
 
int main(void){free(0)}

Which one of the following statements is true regarding the above code in Standard C?
Choice 1

The freeing of a null pointer will cause a program crash.
Choice 2

The code is wrong because free is not a standard C function.
Choice 3

malloc should be called before free.
Choice 4

The code is wrong because free does not take one argument.
Choice 5

The call to free will have no effect. (Ans-???)

MultipleChoiceInC 6May2008 04:55

Re: 100 Multiple choice questions in C
 
New Question:

double d[128];

Considering the above array d which below code will write the contents of the array d to the stream indicated by the pointer p?
Choice 1

fprintf(p, "%[128d", d);
Choice 2

fwrite(d, sizeof(double), sizeof(d), p);
Choice 3

fwrite(d, sizeof(d), sizeof(double), p);
Choice 4

write(fp, d, sizeof(d));
Choice 5

fwrite(d, sizeof(*d), 128, p);

MultipleChoiceInC 6May2008 05:01

Re: 100 Multiple choice questions in C
 
Which one of the following appends the character '?' to the string str ?
Choice 1

strcat(str,"\?"); (Ans--?)
Choice 2

strccat(str,'?');
Choice 3

strapp(str,'?');
Choice 4

strcat(str,'?');
Choice 5

strcon(str,"?");

MultipleChoiceInC 6May2008 05:02

Re: 100 Multiple choice questions in C
 
Which one of the following is a true statement about an lvalue?
Choice 1

An lvalue is, by definition, the value appearing on the rightmost side of an assignment statement.
Choice 2

By definition, an lvalue is the storage space indirectly referenced by a pointer.
Choice 3

All lvalues can be used on the right side of an assignment statement. (Ans--?)
Choice 4

An lvalue is the result of an arithmetic operation involving quantities of type long int.

MultipleChoiceInC 6May2008 05:05

Re: 100 Multiple choice questions in C
 
void crash(void){
printf("got there");
((char*) 0)=0;

}
The function crash(), defined above, triggers a fault in the memory management hardware for many architectures. Which one of the following explains why "got here" may NOT be printed before the crash?
Choice 1

There is insufficient information to determine why the output fails to appear. A broader context is required.
Choice 2

printf() expects more than a single argument. Since only one argument is given, the crash may actually occur inside printf(), which explains why the string is not printed. puts() should be used instead.
Choice 3

If the standard output stream is buffered, the library buffers may not be flushed before the crash occurs. (Ans--?)
Choice 4

printf() always buffers output until a newline character appears in the buffer. Since no newline was present in the format string, nothing is printed.

MultipleChoiceInC 6May2008 05:06

Re: 100 Multiple choice questions in C
 
What is a variable DECLARATION (as opposed to a variable definition)?
Choice 1

The assignment of properties and an identifier (a name) to a variable (Ans---?)
Choice 2

The assignment of storage space to a variable
Choice 3

The assignment of properties and storage space to a variable

MultipleChoiceInC 6May2008 05:09

Re: 100 Multiple choice questions in C
 
Which one of the following is true about null pointers?
Choice 1

The null pointer is a pointer to a string of zero (0) width; that is, it is a pointer to the NUL character.
Choice 2

The null pointer is the pointer in which the value is zero (0).
Choice 3

The null pointer is any uninitialized pointer.
Choice 4

The null pointer is the pointer in which the value is the value of a constant defined several places throughout the standard library. ()
Choice 5

The null pointer is known to point to no object and is represented in C expressions by a pointer-typed zero (0). (Ans--?)

MultipleChoiceInC 6May2008 05:13

Re: 100 Multiple choice questions in C
 
unsigned int x=0;
(x^x)||x++||++x||x++;

What is the value of "x" after the execution of the above sample code?
Choice 1

1
Choice 2

2 (Ans--??)
Choice 3

3
Choice 4

The value is undefined because "x" is initialized to 0.

MultipleChoiceInC 6May2008 05:14

Re: 100 Multiple choice questions in C
 
A right shift is arithmetic if it propagates the sign bit of its principal operand. The C standard grants compiler writers the freedom to determine whether or not right shifts should be arithmetic. Given the definition above, which one of the following is functionally equivalent to an arithmetic right shift of signed int x by two (2) and is guaranteed to be portable?
Choice 1

x / 4 (Ans---??)
Choice 2

x / 2
Choice 3

x >>> 2
Choice 4

x >> 2
Choice 5

x > 0 ? x >> 2 | 1 << sizeof(x) * 8 - 1 : x >> 2

MultipleChoiceInC 6May2008 08:45

Re: 100 Multiple choice questions in C
 
char var1[10];
char var2[5]="hello";
strcpy(var1,var2);
printf("%s,%s",var1,var2);

What does the above code print?
Choice 1

Nothing, the link fails with an array overflow error.
Choice 2

"Hello Hello"
Choice 3

It is unknown; the results are undefined, and depending on the platform, the code may cause an access violation or core dump.
Choice 4

Nothing, the compilation fails, because only string pointers can be initialized with a string literal.
Choice 5

Nothing, the program fails with an "array overflow" runtime error message before printing anything.

shabbir 6May2008 09:14

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by MultipleChoiceInC
int main(void){free(0)}

Which one of the following statements is true regarding the above code in Standard C?
Choice 1

The freeing of a null pointer will cause a program crash.
Choice 2

The code is wrong because free is not a standard C function.
Choice 3

malloc should be called before free.
Choice 4

The code is wrong because free does not take one argument.
Choice 5

The call to free will have no effect. (Ans-???)

The freeing of a null pointer will cause a program crash.

shabbir 6May2008 09:15

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by MultipleChoiceInC
New Question:

double d[128];

Considering the definition of d above, which one of the following code fragments portably writes the contents of the array d to the stream indicated by fp in native representation?
Choice 1

fprintf(fp, "%[128d", d);
Choice 2

fwrite(d, sizeof(double), sizeof(d), fp);
Choice 3

fwrite(d, sizeof(d), sizeof(double), fp);
Choice 4

write(fp, d, sizeof(d));
Choice 5

fwrite(d, sizeof(*d), 128, fp);

Checkout the function signature and that would help

shabbir 6May2008 09:15

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by MultipleChoiceInC
Which one of the following appends the character '?' to the string str ?
Choice 1

strcat(str,"\?"); (Ans--?)
Choice 2

strccat(str,'?');
Choice 3

strapp(str,'?');
Choice 4

strcat(str,'?');
Choice 5

strcon(str,"?");

strcat(str,"\?");

shabbir 6May2008 09:16

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by MultipleChoiceInC
Which one of the following is a true statement about an lvalue?
Choice 1

An lvalue is, by definition, the value appearing on the rightmost side of an assignment statement.
Choice 2

By definition, an lvalue is the storage space indirectly referenced by a pointer.
Choice 3

All lvalues can be used on the right side of an assignment statement. (Ans--?)
Choice 4

An lvalue is the result of an arithmetic operation involving quantities of type long int.

By definition, an lvalue is the storage space indirectly referenced by a pointer.

shabbir 6May2008 09:17

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by MultipleChoiceInC
void crash(void){
printf("got there");
((char*) 0)=0;

}
The function crash(), defined above, triggers a fault in the memory management hardware for many architectures. Which one of the following explains why "got here" may NOT be printed before the crash?
Choice 1

There is insufficient information to determine why the output fails to appear. A broader context is required.
Choice 2

printf() expects more than a single argument. Since only one argument is given, the crash may actually occur inside printf(), which explains why the string is not printed. puts() should be used instead.
Choice 3

If the standard output stream is buffered, the library buffers may not be flushed before the crash occurs. (Ans--?)
Choice 4

printf() always buffers output until a newline character appears in the buffer. Since no newline was present in the format string, nothing is printed.

If the standard output stream is buffered, the library buffers may not be flushed before the crash occurs.

shabbir 6May2008 09:17

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by MultipleChoiceInC
What is a variable DECLARATION (as opposed to a variable definition)?
Choice 1

The assignment of properties and an identifier (a name) to a variable (Ans---?)
Choice 2

The assignment of storage space to a variable
Choice 3

The assignment of properties and storage space to a variable

I am not sure what does variable definition means but it should be some thing like defining the class.

shabbir 6May2008 09:19

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by MultipleChoiceInC
Which one of the following constitutes a true statement about the null pointer?
Choice 1

The null pointer is a pointer to a string of zero (0) width; that is, it is a pointer to the NUL character.
Choice 2

The null pointer is the pointer in which the value is zero (0).
Choice 3

The null pointer is any uninitialized pointer.
Choice 4

The null pointer is the pointer in which the value is the value of a constant defined several places throughout the standard library. ()
Choice 5

The null pointer is known to point to no object and is represented in C expressions by a pointer-typed zero (0). (Ans--?)

My answer would be The null pointer is the pointer in which the value is zero (0). but then its debatable.

shabbir 6May2008 09:19

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by MultipleChoiceInC
unsigned int x=0;
(x^x)||x++||++x||x++;

What is the value of "x" after the execution of the above sample code?
Choice 1

1
Choice 2

2 (Ans--??)
Choice 3

3
Choice 4

The value is undefined because "x" is initialized to 0.

Check with your compiler

shabbir 6May2008 09:20

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by MultipleChoiceInC
A right shift is arithmetic if it propagates the sign bit of its principal operand. The C standard grants compiler writers the freedom to determine whether or not right shifts should be arithmetic. Given the definition above, which one of the following is functionally equivalent to an arithmetic right shift of signed int x by two (2) and is guaranteed to be portable?
Choice 1

x / 4 (Ans---??)
Choice 2

x / 2
Choice 3

x >>> 2
Choice 4

x >> 2
Choice 5

x > 0 ? x >> 2 | 1 << sizeof(x) * 8 - 1 : x >> 2

x / 4

shabbir 6May2008 09:21

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by MultipleChoiceInC
char var1[10];
char var2[5]="hello";
strcpy(var1,var2);
printf("%s,%s",var1,var2);

What does the above code print?
Choice 1

Nothing, the link fails with an array overflow error.
Choice 2

"Hello Hello"
Choice 3

It is unknown; the results are undefined, and depending on the platform, the code may cause an access violation or core dump.
Choice 4

Nothing, the compilation fails, because only string pointers can be initialized with a string literal.
Choice 5

Nothing, the program fails with an "array overflow" runtime error message before printing anything.

"Hello Hello"
but there should be a comma (,) in between both the hello's

psapikas 6May2008 19:09

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by shabbir
"Hello Hello"
but there should be a comma (,) in between both the hello's

I think this result should be printed if the second array was defined as: var2[6]

brajrajsingh 14May2008 12:38

Re: 100 Multiple choice questions in C
 
Also Please mail the answers to brajrajsingh@gmail.com

MultipleChoiceInC 22May2008 03:13

Re: 100 Multiple choice questions in C (New Question?)
 
char buf[50]="Hello World";
char *ptr=buf+5;

What's the right way to copy 15 bytes from the location pointed by "ptr" to the beginning of "buf"?
Choice 1
memmove( buf, ptr, 15 ); (ans)

Choice 2
Illegal memory access because it will read memory past the end of the string.

Choice 3
strncpy( buf, ptr, 15 );

Choice 4
Cannot be done because the source and destination overlap.

Choice 5
memcpy( buf, ptr, 15 );

MultipleChoiceInC 22May2008 03:16

Re: 100 Multiple choice questions in C (Ask New Questions?)
 
struct node {
int id;
int lengh;
struct node *next;
struct node *prev;
unsighed char data[1];
}

Considering struct node, an aggregate type defined above, which one of the following might explain the declaration of its peculiar member data?
Choice 1

There is no difference between character unsigned char data and array unsigned char data [1] since each allocates only a single byte. Identical operations can be performed on both quantities. The choice was one of preference.
Choice 2

The programmer is declaring a bit field called data, which consists of only a single bit. struct node probably represents some hardware device.
Choice 3

data is probably used in conjunction with length and malloc() to create objects of variable size. struct node is essentially a header for an object of indeterminate size.
Choice 4

The information provided by the definition of struct node is insufficient to formulate a guess about the purpose of the member data or its strange declaration. (Ans)
Choice 5

The programmer has made a typo. If the programmer had intended to allocate only a single byte, the data would have been declared as unsigned char data instead.


All times are GMT +5.5. The time now is 23:31.