0
MultipleChoiceInC's Avatar
Go4Expert Member
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.
0
MultipleChoiceInC's Avatar
Go4Expert Member
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++.
0
MultipleChoiceInC's Avatar
Go4Expert Member
#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'
0
madlex's Avatar, Join Date: Jun 2008
Go4Expert Member
Quote:
Originally Posted by shabbir
By definition, an lvalue is the storage space indirectly referenced by a pointer.
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
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
So it means indirectly referenced by pointer. Your example of something also does the same.
0
madlex's Avatar, Join Date: Jun 2008
Go4Expert Member
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
0
Samdani's Avatar, Join Date: Jun 2008
Newbie Member
pls can anyone send me the answers at samdanikalpesh@gmail.com
0
XXxxImmortalxxXX's Avatar
Invasive contributor
mate your not allowed to advertise on this forum like that
0
amit8_j's Avatar
Newbie Member
Please send me the answers to these questions at my ID amit8.j@tcs.com
Thanks
Amit
0
guneet's Avatar, Join Date: Mar 2009
Newbie Member
wud u plz send me answers for these 100 mcqs at the undersigned-as soon as possible!!
guneet2027@gmail.com