100 Multiple choice questions in C

Discussion in 'C' started by coderzone, Apr 2, 2006.

  1. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Don't you think that should not be in this thread.
     
  2. PythonNewbie

    PythonNewbie New Member

    Joined:
    Jun 25, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Can you please mail me the answers at mpolyadis@gmail.com
    Thank you very much , in advance for your reply .......
     
  3. wrecker

    wrecker New Member

    Joined:
    Mar 12, 2007
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    0
    No dude, i still think that the answer is (1). Go and Google. Ya, although different compilers would use different identifier rules.
     
  4. fengxueye

    fengxueye New Member

    Joined:
    Jul 2, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
  5. JamC

    JamC New Member

    Joined:
    Jun 23, 2007
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    0
    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...
     
  6. psapikas

    psapikas New Member

    Joined:
    Aug 1, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Mathematician
    Location:
    Athens
    Hello, could u please explain to me the solution of questions #44, #51 and #91?
    Thanks in advance
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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.
     
  8. psapikas

    psapikas New Member

    Joined:
    Aug 1, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Mathematician
    Location:
    Athens
    Thanks for your answers :)
     
  9. ec_ashish

    ec_ashish New Member

    Joined:
    Aug 21, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
  10. sudheer157

    sudheer157 New Member

    Joined:
    Aug 22, 2007
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  11. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    what explanation you want for the function.
     
  12. sudheer157

    sudheer157 New Member

    Joined:
    Aug 22, 2007
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Hi
    I Want Solutin For Q No 67..
     
  13. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Choice is 4
     
  14. indian.21987

    indian.21987 New Member

    Joined:
    Aug 19, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    *question number 1*/

    Code:
    int z,x=5,y=-10,a=4,b=2;
    z = x++ - --y * b / a;What number will z in the sample code above contain?




    In this,I think the answer is 10
    But It is given that 12 is the ans.
    How is it possible?
    Please can you explain it?
    Thank you.
     
  15. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Why don't you try and Run it on your compiler and see what is the output.
     
  16. sudheer157

    sudheer157 New Member

    Joined:
    Aug 22, 2007
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Hi can some one please tell me the answers for the following
    Q19
    Q45
    Q64
    Q69
    Thanks in advance.
     
  17. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Hi can some one please tell me the answers for the following
    I would go for choice 1 as other are not relevant to the cause of the problem.
    Choice 4 and the choice itself tells the reason
    Choice 2 as the pointer base address is changed by p++
    Choice 1 and the reason lies in the choice option itself.
     
  18. sudheer157

    sudheer157 New Member

    Joined:
    Aug 22, 2007
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    THANQ so much...for your reply...i need solutions to few more.i will be very thankful to you and i need solutions for the following
    Q72
    Q75
    Q83
    Q96
    Q100
    please help me out.
     
  19. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Here they come.
    Choice is 3
    Discussion is there in the comments.
    I would vote for choice 4
    Choice 1 and if you have doubt in such a small question you should refer to some standard C book.
    private is not a C keyword and so I would go for choice 1.
     
  20. sudheer157

    sudheer157 New Member

    Joined:
    Aug 22, 2007
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    hi shabbir
    ihave doubts in the following questions please help me out.i m attaching those questions in a zip file as they are bmp images.
    please give me the solutions either to my mail sudheer157@yahoo.com or in this forum itself.

    <<Attachment Removed>>
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice