Wednesday, February 10, 2010

What number will z in the sample code contain?

int z,x=5,y=-10,a=4,b=2;
z = x++ - --y * b / a;

a) 5
b) 6
c) 10
d) 11
e) 12

Understanding Stack and Queue

The five items: A, B, C, D and E are pushed in a stack,one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack.
The popped item is


a) A
b) B
c) C
d) D

fputs function is used to ?

i. write characters to a file
ii. takes 2 parameters
iii. returns a character
iv. requires a file pointer

a) all are true
b) all are false
c) only i and ii are true
d) only i,ii and iv are true


What is the output of this program?

main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}

a) program will not compile
b) 10
c) god only knows
d) address of i

Monday, February 8, 2010

What is the output of following programme ?

# include
# define a 10
main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}

a) 10..10
b) 10..50
c) Error
d) 0