1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

100 Multiple choice questions in C

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

  1. MultipleChoiceInC

    MultipleChoiceInC New Member

    Joined:
    May 4, 2008
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Re: 100 Multiple choice questions in C(New Question?)

    Which one of the following Standard C functions can be used to sort a string array?
    Choice 1

    qsort (Ans)
    Choice 2

    sort
    Choice 3

    quicksort
    Choice 4

    asort
    Choice 5

    There is no Standard C function for such a sort.
     
  2. MultipleChoiceInC

    MultipleChoiceInC New Member

    Joined:
    May 4, 2008
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    int a[100];
    int *p=a;

    for(;a<p+100; a++)
    *a=0;

    a=p;

    Which one of the following describes the error in the sample code above?
    Choice 1

    The initialization of p from a is not allowed since the compiler believes that they have differing types. There should be whitespace between the star and p to achieve the desired effect.
    Choice 2

    It is not permissible to omit the initializer of a for loop.
    Choice 3

    The address of the first element not in the array a is p + 100 * sizeof(int), not p + 100.
    Choice 4

    It is not permissible to alter the value of a. (Ans)
    Choice 5

    The iterator of the for loop should be a += sizeof(int) instead of a++.
     
  3. MultipleChoiceInC

    MultipleChoiceInC New Member

    Joined:
    May 4, 2008
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Re: 100 Multiple choice questions in C(New Q?)

    #include <stdlib.h>

    int main()
    {
    struct x {double d; int i; char c;};

    struct x *xp=(struct x*)calloc(1, sizeof(struct x));

    }

    Referring to the above sample code, what are the values of the structure members pointed to by "xp" after the "calloc"?
    Choice 1

    undefined,undefined,undefined
    Choice 2

    1.0,1,'\01'
    Choice 3

    undefined,0,'\0' (Ans)
    Choice 4

    0.0,0,'\0'
    Choice 5

    0e0,0,'\0'
     
  4. madlex

    madlex New Member

    Joined:
    Jun 6, 2008
    Messages:
    12
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Technical Project Manager
    Location:
    Bucharest,RO
    I am not that sure that is the answer.
    By definition an lvalue is a "value" that can take part in an assigment on the left side. More particular, the lvalue is a "writable" value, and an rvalue is a "readable" value. Nothing to do with pointers.
    for example:
    (1+2) its a rvalue -> we could never write (1+2) = 4 :P
    but this is a lvalue but also a rvalue
    int & something()
    {
    static int something = 0;
    return something;
    }
    something() = 3; // something() as lvalue
    int some_thing = something(); // something() as rvalue
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    So it means indirectly referenced by pointer. Your example of something also does the same.
     
  6. madlex

    madlex New Member

    Joined:
    Jun 6, 2008
    Messages:
    12
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Technical Project Manager
    Location:
    Bucharest,RO
    Code:
    //  Oki, but what pointer reference do we have here?
    const int anything = 12;
    int some_thing = anything;
    some_thing = 0; // lvalue = rvalue
    // Consider that we can use a pointer to point to an rvalue also
    const char * pszSomething = "Hello";
    // Considering the statement above, what would be the difference between rvalue and lvalue
    // if this is the definition of an lvalue?!
    
    That's why I think the choice "All lvalues can be used on the right side of an assignment statement. (Ans--?)" was marked as the answer, because is the most plausible of all. This means that If a value is a lvalue it can also be used as an rvalue.

    And about the function int & something(); I used in the previous example,I should say that not all the references are "translated" by the compiler into pointers.In this case, it should not. But that's debatable depending on what do you mean by "pointer".

    If I am wrong correct me please.
    Cheers
     
  7. Samdani

    Samdani New Member

    Joined:
    Jun 23, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
  8. XXxxImmortalxxXX

    XXxxImmortalxxXX New Member

    Joined:
    Jun 27, 2007
    Messages:
    569
    Likes Received:
    18
    Trophy Points:
    0
    mate your not allowed to advertise on this forum like that
     
  9. amit8_j

    amit8_j New Member

    Joined:
    Dec 8, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Please send me the answers to these questions at my ID amit8.j@tcs.com
    Thanks
    Amit
     
  10. guneet

    guneet New Member

    Joined:
    Mar 17, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Re: 100 Multiple choice questions in C !!i need answers!!

    wud u plz send me answers for these 100 mcqs at the undersigned-as soon as possible!!
    guneet2027@gmail.com
     
  11. mishra.vaibhav00

    mishra.vaibhav00 New Member

    Joined:
    Mar 24, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
  12. vartika

    vartika New Member

    Joined:
    Apr 3, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hello
    plz mail me answers at vartika.mishra27@gmail.com
    im making a website on online examination as my project so i need ans of the question...
    is the option mark as [ans] is the right answer plz tel me so that i can complete my website...
     
  13. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    yes ans marked are answers but I am not sure we have them for all
     
  14. archag

    archag New Member

    Joined:
    Apr 10, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
  15. JamC

    JamC New Member

    Joined:
    Jun 23, 2007
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    0
    Best post of the entire thread...
     
  16. elkovou

    elkovou New Member

    Joined:
    May 4, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
  17. elkovou

    elkovou New Member

    Joined:
    May 4, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
  18. elkovou

    elkovou New Member

    Joined:
    May 4, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
  19. muthu4love

    muthu4love New Member

    Joined:
    Aug 25, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
  20. monicka

    monicka New Member

    Joined:
    Jan 14, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0

Share This Page