char buf [] = "Hello world!";
char * buf = "Hello world!";
a) The first definition certainly allows the contents of buf to be safely modified at runtime; the second definition does not
b) The first definition is not suitable for usage as an argument to a function call; the second definition is
c) The first definition is not legal because it does not indicate the size of the array to be allocated; the second definition is legal
d) They do not differ -- they are functionally equivalent
e) The first definition does not allocate enough space for a terminating NUL-character, nor does it append one; the second definition does
Sunday, January 10, 2010
Which one of the following will declare a pointer to an integer at address 0x200 in memory?
a) int *x;
*x = 0x200;
b) int *x = &0x200;
c) int *x = *0x200;
d) int *x = 0x200;
e) int *x( &0x200 );
*x = 0x200;
b) int *x = &0x200;
c) int *x = *0x200;
d) int *x = 0x200;
e) int *x( &0x200 );
What string does ptr point to in the sample code below?
char *ptr;
char myString[] = "abcdefg";
ptr = myString;
ptr += 5;
a) fg
b) efg
c) defg
d) cdefg
e) None of the above
char myString[] = "abcdefg";
ptr = myString;
ptr += 5;
a) fg
b) efg
c) defg
d) cdefg
e) None of the above
What value will x contain when the sample code below is executed?
int x = 3;
if( x == 2 );
x = 0;
if( x == 3 )
x++;
else x += 2;
a) 1
b) 2
c) 3
d) 4
e) 5
if( x == 2 );
x = 0;
if( x == 3 )
x++;
else x += 2;
a) 1
b) 2
c) 3
d) 4
e) 5
Tuesday, December 15, 2009
Ternary Operator
What is the output.
int main()
{
int i=10,j=20;
j = i, j?(i,j)?i:j:j;
printf("%d %d",i,j);
}
Choice:
a)10 10
b)20 20
c)10 11
d)11 10
e)10 20
int main()
{
int i=10,j=20;
j = i, j?(i,j)?i:j:j;
printf("%d %d",i,j);
}
Choice:
a)10 10
b)20 20
c)10 11
d)11 10
e)10 20
Subscribe to:
Posts (Atom)