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 13Jun2007 08:50

Re: 100 Multiple choice questions in C
 
Quote:

Originally Posted by AHMAD
How Are You

Don't you think that should not be in this thread.

PythonNewbie 25Jun2007 14:10

Re: 100 Multiple choice questions in C
 
Can you please mail me the answers at mpolyadis@gmail.com
Thank you very much , in advance for your reply .......

wrecker 30Jun2007 18:42

Re: 100 Multiple choice questions in C
 
No dude, i still think that the answer is (1). Go and Google. Ya, although different compilers would use different identifier rules.

fengxueye 2Jul2007 22:08

Re: 100 Multiple choice questions in C
 
Please send me the answers for these questions
fengxueye@hotmail.com

Thanks

JamC 29Jul2007 10:48

Re: 100 Multiple choice questions in C
 
Question #10
Code:

int a=10,b;
b=a++ + ++a;
printf("%d,%d,%d,%d",b,a++,a,++a);

Hmm, this is undefined- suprised nobody caught this

Question 97

Code:

int m = -14;
int n = 6;
int o;
o = m % ++n;
n += m++ - o;
m <<= (o ^ n) & 3;

If one of the operands is negative, the sign of the result is machine dependent...

psapikas 1Aug2007 13:12

Re: 100 Multiple choice questions in C
 
Hello, could u please explain to me the solution of questions #44, #51 and #91?
Thanks in advance

shabbir 1Aug2007 14:04

Re: 100 Multiple choice questions in C
 
Here comes the explanation to your questions:
Question #44
increment( i ) is a local function and the value of i that is incremented inside the function will not be reflected in the main function and so the loop will never end because the loop variable is not changed.
Question #51
The condition is tested and then the loop breaks giving you the value as 5 outside the loop.
Question #91
Static variables are stored in heap and preserve the value for the execution of the program and so it does not reset for each function call where as other variable are allocated in the stack which gets destroyed when the function returns.

psapikas 1Aug2007 17:07

Re: 100 Multiple choice questions in C
 
Thanks for your answers :)

ec_ashish 21Aug2007 19:03

Re: 100 Multiple choice questions in C
 
Please send me the answers for these questions at ec.ashish@gmail.com

sudheer157 22Aug2007 21:35

Re: 100 Multiple choice questions in C
 
can some one please tell me the answer for this Q?
Thanks in advance..


* sys/cdef.h */
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
/* stdio.h */
#include <sys/cdefs.h>
div_t div __P((int, int));
The code above comes from header files for the FreeBSD implementation of the C library. What is the primary purpose of the __P() macro?
Choice 1
The __P() macro has no function, and merely obfuscates library function declarations. It should be removed from further releases of the C library.
Choice 2
The __P() macro provides forward compatibility for C++ compilers, which do not recognize Standard C prototypes.
Choice 3
Identifiers that begin with two underscores are reserved for C library implementations. It is impossible to determine the purpose of the macro from the context given.
Choice 4
The __P() macro provides backward compatibility for K&R C compilers, which do not recognize Standard C prototypes.
Choice 5
The __P() macro serves primarily to differentiate library functions from application-specific functions.


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