Tải bản đầy đủ (.pdf) (12 trang)

100 c interview questions answers

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (82.71 KB, 12 trang )

1.
ans: (a)
reason:
you cannot declare structure as unsized array.

2.
ans: (b)
reason:
The return st.. returns x value first as it is and then
decrements its value.
Its post decrement.

3.
ans: (e)
reason:
%p represents the pointer format specifier. It prints the
value in
hexa decimal upto four digits
4.
ans: (b)

5.
ans: (b)
reason:
The values in the if st.. () is said to be in the stack. So
the last element
in the stack is taken as check value(zero/non-zero). Here TRUE
is -1 i.e.
success stateand x+y is printed.

6.


/* Unsolved*/

7.
ans: (c)
reason:
Static initializes all to 0.
8.


ans: (b)
reason:
char pointer size = 1
int pointer size = 2

9.
ans: (d)
reason:
10.
ans: (c)
reason:
printf returns the total no.. of characters it prints on the
screen.

11.
ans: (c)
unsolved*/
12.
reason:
;;; doesnot matter. This indicates only an empty statement.
The o/p will be 3,1.

13.
ans: (b)
14.
ans: (d)
reason:
The puts prints and places the cursor in the next line,
whereas
the printf prints and places the cursor in the same line.
15.
ans: (c)
reason:
You need to put '=' sign at show. ie the correct st.. is
end=(char*)(show=(char*)strcpy(start,"MISPIS,"));
or else expression error.


16.
ans: (e)
reason:
The _fastcall keyword is reserved for
programming under Windows and OS/2.
17.
ans: (a)
reason:
The strcmp returns 0 if zone==target, If 0 the ?: assigns fail
st.. i.e. 0.
This is false value for IF st.. and hence else part is
executed.

18.

ans: (c)
reason:
t1 is an array. So you need to specify the subscript value
while
you assign any element to it.
char *t1; t1="craft" is correct since *t1 is a pointer and it
points
to the starting addr.. of the craft.
19.
ans: (b).
unsolved

20.
ans: (b)

21.
ans: (a)
reason:
Its a static array.

22.
ans: (b)


unsolved

23.
ans : (a)

24.

ans: (d)
25.
ans: (c)
reason:
c+ +100 is not valid as c=c+100

26.
ans: (d)

27.
ans: (a)

28.
ans: (b)
29.
ans: (a)
30.
ans:(c)

31.
ans: (d)

32.
ans: (e)
reason: incompatiable type conversions

33.
ans: (c)
reason: odd no.. AND with 1 gives TRUE value always.



34.
ans:
(b)
reason:
if we mention the string as two dimentional(for more than
one dim)
array with in printf statement,then we should give
'&'symbol

35.
ans: (b)
reason:
res=0+1/5;
res=1/5+1/4;
res=1/5+1/4+1/3;
....
res=1/5+1/4+1/3+1/2+1/1;
At last time
res=1/5+1/4+1/3+1/2+1/1+1/0;
^
|
zero divide occur

36.
ans:

(b)

reason:

'%c' mainly used for print one charactor
We can't specify formate output within '%c'
37.
ans: (b)
reason:
can not modify constant value .
It is a fixed value for entire program.
38.
ans: (b)
reason:
'argc' holds number of arguments.
argc consist always value 1 becase file name is one of the
input .
therefore 1<1 gives false whereas 1==1 gives true.


39.
ans: (a)
reason:
% followed by non-format specifier is printed as such
with % symbol
40.
ans : (b)
reason: if no format specifier is given immediately after the
first appearance of % then the characters after the % are
printed as such
41.
ans: (d)
reason:
the scanf must have &x,&y for %d format specifiers.

42.
ans: (a)
reason:
In if statement, x=6 is assigned and not checked.
43.
ans: (d)
reason: self
44.
ans: (a)
reason:
+ve

odometer principle, since a is unsigned it is always

45.
ans: (a)
reason: self
46.
ans: (e)


reason: unsolved

47.
ans: (c)
reason: x will contain the garbage value hence default

48.
ans: (b)
reason: x will contain the garbage value hence default


49.
ans: (b)
reason: self
50.
ans: (b)
reason: self

51.
ans: (b)
reason: recursive function

52.
ans: (d)
reason: t is a pointer and memory allocation is not needed for
that.

53.
ans: (a)
reason: Each 0 bit in the operand is set to 1, and each 1 bit
in the operand is set to 0 if we use ~
54.
ans: (c)


reason: int x:8 will get only first 8 bits assigned to it ie.,
1 byte of size
int x:9 will get only first 9 bits assigned to it ie., 2 byte
of size
1 2 3 4 5 6 7 8

x : 8
x : 9

a a a a a a a a
n n n
n n n n n
a a a a a a a a
a n n
n n n n n
-----------------------------------1 byte
1 byte

55.
ans: (e)
reason:
56.
ans: (b)
reason: self
57.
ans: (d)
reason: self

58.
ans: (a)
reason: can't understand
59.
ans: (b)
reason: self

60.

ans: (c)
reason:
61.

9 10 11 12 13 14 15 16


ans: (1)
reason: self
62.
ans: (b)

63.
ans: (c)

64.
ans: (a)
65.
ans:(c)
66.
ans: (f)

67.
ans: (b)
reason : if you give int main() it goes to infinite loop.
68.
ans: (d)

69.
ans: (b)


70.
ans: (b)
71.
ans: (c)
72.
ans: (e)
73.
ans: (b)


reason: if name is given the output is hai

74.
ans: (a)
75.
ans: (b)

76.
ans: (a)

77.
ans:

(c)

78.
ans: (c)
79.
ans: (a)

80.
ans: (a)
81.

82.
ans: (d)
reason : pointers cannot be added
83.
ans: (d)

84.
ans: (b)
reason: stack concept


85.
ans: (b)

86.
ans: (a)

87.
ans: (c)
88.
ans: (c)
89.
ans: (a)
90.
ans: (a)


91.
92.

93.
ans:(c)
94.
ans: (d)
reason: message[] is correct

95.
ans: (c)
reason: static is not allowed in main(..). If removed, junk
value.
96.
ans: (a)
reason: self


97.
ans: (b)
reason:

98.
ans: (a)
99.
ans: (b)
reason:

100.
ans: (c)

reason: *_ is an allowed variable



×