C Interview Questions

 
1.
What is C language?
2.
What is Duffs Device?
3.
Here is a good puzzle: how do you write a program which produces its own source code as output?
4.
Suggesting that there can be 62 seconds in a minute?
5.
Was 2000 a leap year?
6.
How can I find the day of the week given the date?
7.
What is hashing in C?
8.
I need a sort of an approximate strcmp routine ...
9.
What is C Programing language?
10.
How can I call FORTRAN?
11.
What is assert and when would I use it?
12.
Why doesnt C have nested functions?
13.
Does C have an equivalent to Pascals with statement?
14.
If the assignment operator were ...
15.
Is C a great language, or what?
16.
Does C have circular shift operators?
17.
There seem to be a few missing operators ...
18.
Why isnt there a numbered, multi-level break statement to break out
19.
Why dont C comments nest?
20.
Are the outer parentheses in return statements really optional?
21.
Is there a way to have non-constant case labels (i.e. ranges or arbitrary expressions)?
22.
Is there a way to switch on strings?
23.
Which is more efficient, a switch statement or an if else chain?
24.
How can I swap two values without using a temporary?
25.
People claim that optimizing compilers are good and that we no longer have to write things in assembler for speed
26.
I have been replacing multiplications and divisions with shift operators, because shifting is more efficient.
27.
Are pointers really faster than arrays?
28.
What is the best way of making my program efficient?
29.
What is the most efficient way to count the number of bits which are set in an integer?
30.
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?
31.
How can I convert integers to binary or hexadecimal?
32.
How do I swap bytes?
33.
How can I determine whether a machines byte order is big-endian or little-endian?
34.
How can I implement sets or arrays of bits?
35.
How can I manipulate individual bits?
36.
If I have a char * variable pointing to the name of a function ...
37.
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
38.
What is the right way to use errno?
39.
What is a good data structure to use for storing lines of text?
40.
How can I return multiple values from a function?
41.
Why isnt any of this standardized in C? Any real program has to do some of these things.
42.
But I cant use all these nonstandard, system-dependent functions, because my program has to be ANSI compatible!
43.
What are near and far pointers?
44.
I am trying to compile this program
45.
How can I ensure that integer arithmetic doesnt overflow?
46.
How can I handle floating-point exceptions gracefully?
47.
How can I trap or ignore keyboard interrupts like control-C?
48.
How can I implement a delay, or time a users response, with sub-second resolution?
49.
How can I read in an object file and jump to locations in it?
50.
Is exit(status) truly equivalent to returning the same status from main?
51.
How can I open files mentioned on the command line, and parse option flags?
52.
How can a process change an environment variable in its caller?
53.
How can I automatically locate a programs configuration files in the same directory as the executable?
54.
How can my program discover the complete pathname to the executable from which it was invoked?
55.
How can I invoke another program or command and trap its output?
56.
How do I get an accurate error status return from system on MS-DOS?
57.
How can I call system when parameters (filenames, etc.) of the executed command arent known until run time?
58.
How can I invoke another program (a standalone executable, or an operating system command) from within a C program?
59.
How can I do PEEK and POKE in C?
60.
I thought that using large model meant that I could use more than 64K of data!
61.
How can I allocate arrays or structures bigger than 64K?
62.
How can I find out how much memory is available?
63.
How do I create a directory? How do I remove a directory (and its contents)?
64.
How can I read a directory in a C program?
65.
How can I find out how much free space is available on disk?
66.
How can I increase the allowable number of simultaneously open files?
67.
fopen isnt letting me open files like "$HOME/.profile" and "~/.myrcfile".
68.
Why cant I open a file by its explicit path?
69.
How do I copy files?
70.
How can I delete a file?
71.
How can I recover the file name given an open stream or file descriptor?
72.
ow can I insert or delete a line (or record) in the middle of a file?
73.
How can I find the modification date and time of a file?
74.
How can I find out the size of a file, prior to reading it in?
75.
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
76.
How can I send mail from within a C program?
77.
How can I do graphics in C?
78.
How can I access an I O board directly?
79.
How do I send escape sequences to control a terminal or other device?
80.
How can I direct output to the printer?
81.
How can I do serial comm port I O?
82.
How do I read the arrow keys? What about function keys?
83.
How can I make it pause before closing the program output window?
84.
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
85.
How can I find out if there are characters available for reading?
86.
I need code to parse and evaluate expressions.
87.
Dont ANSI function prototypes render lint obsolete?
88.
Where can I get an ANSI-compatible lint?
89.
How can I shut off the warning ...
90.
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
91.
People always say that good style is important
92.
What is Hungarian Notation? Is it worthwhile?
93.
Should I use symbolic names like TRUE and FALSE for Boolean constants, or plain 1 and 0?
94.
If NULL and 0 are equivalent as null pointer constants, which should I use?
95.
I came across some code that puts a (void) cast before each call to printf. Why?
96.
I have seen function declarations that look like this
97.
Why do some people write if(0 == x) instead of if(x == 0)?
98.
Here is a neat trick for checking whether two strings are equal
99.
How should functions be apportioned among source files?
100.
What is the best style for code layout in C?
101.
Why does this code crash?
102.
This program runs perfectly on one machine ...
103.
I have a program that seems to run correctly
104.
This program crashes before it even runs!
105.
Why isnt my procedure call working? The compiler seems to skip right over it
106.
I am getting baffling syntax errors which make no sense at all
107.
Why is this loop always executing once?
108.
How can I call a function with an argument list built up at run time?
109.
I cant get va_arg to pull in an argument of type pointer-to-function.
110.
I have a varargs function which accepts a float parameter
111.
My compiler isnt letting me declare a function
112.
How can I discover how many arguments a function was actually called with?
113.
How can I write a function analogous to scanf
114.
How can I write a function that takes a format string and a variable number of arguments
115.
I had a frustrating problem which turned out to be caused by the line
116.
How can f be used for both float and double arguments in printf? Are not they different types?
117.
I heard that you have to include stdio.h before calling printf. Why?
118.
I am having trouble with a Turbo C program which crashes
119.
What is a good way to implement complex numbers in C?
120.
The predefined constant M_PI seems to be missing from my machines copy of math.h.
121.
Why does not C have an exponentiation operator?
122.
How do I round numbers?
123.
I am sure I have got the trig functions declared correctly, but they are still giving me wrong answers.
124.
My floating-point calculations are acting strangely and giving me different answers on different machines.
125.
I am trying to do some simple trig, and I am #including , but the linker keeps complaining that functions like sin and cos are undefined
126.
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
127.
What does it mean when the linker says that _end is undefined?
128.
What is the difference between memcpy and memmove?
129.
How can I generate floating-point random numbers?
130.
How can I retHow can I return a sequence of random numbers which dont repeat at all?
131.
How can I get random integers in a certain range?
132.
Did C have any Year 2000 problems?
133.
How can I sort more data than will fit in memory?
134.
How can I sort a linked list?
135.
How can I get the current date or time of day in a C program?
136.
How can I split up a string into whitespace-separated fields?
137.
Why do some versions of toupper act strangely if given an upper-case letter?
138.
How do I convert a string to all upper or lower case?
139.
why isnt it being handled properly?
140.
How can I read/write structures from/to data files?
141.
How can I change their mode to binary?
142.
What is the difference between text and binary I/O?
143.
How can I read a binary data file properly?
144.
How can I get back to the interactive keyboard if stdin is redirected?
145.
Once I have used freopen, how can I get the original stdout (or stdin) back?
146.
How can I recover the file name given an open stream?
147.
How can I insert or delete a line (or record) in the middle of a file?
148.
If fflush wont work, what can I use to flush input?
149.
Why does everyone say not to use gets?
150.
What is the deal on sprintfs return value?
151.
Why does everyone say not to use scanf? What should I use instead?
152.
How can I read data from data files with particular formats?
153.
Why doesnt that code work?
154.
Why doesnt this code work?
155.
Why does the call char scanf work?
156.
Why doesnt the call scanf work?
157.
Why doesnt long int work?
158.
What is wrong with this code?
159.
What does the message "Automatic aggregate intialization is an ANSI feature" mean?
160.
What was noalias and what ever happened to it?
161.
What should malloc0 do? Return a null pointer or a pointer to 0 bytes?
162.
What are pragmas and what are they good for?
163.
What is the correct declaration of main?
164.
Can you mix old-style and new-style function syntax?
165.
What is the ANSI C Standard?
166.
How can I list all of the predefined identifiers?
167.
How can I use a preprocessorif expression to ?
168.
Is there anything like an ifdef for typedefs?
169.
What is the difference between #include <> and #include?
170.
What are the complete rules for header file searching?
171.
What is the right type to use for Boolean values in C? Is there a standard type? Should I use #defines or enums for the true and false values?
172.
Why does not
strcat(string, "!");
work?
173.
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
174.
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
175.
How can I dynamically allocate arrays?
176.
What is wrong with this initialization?
177.
How can this be legal C?
178.
Is a pointer a kind of array?
179.
Why ca not I do something like this?
180.
Is NULL valid for pointers to functions?
181.
How do I get a null pointer in my programs?
182.
What is this infamous null pointer, anyway?
183.
What is the total generic pointer type?
184.
Can I initialize unions?
185.
What are pointers really good for, anyway?
186.
Are enumerations really portable?
187.
C is not C++. Typedef names are not automatically generated
188.
What is the auto keyword good for?
189.
What is wrong with this declaration?
190.
Linked Lists -- Can you tell me how to check whether a linked list is circular?
191.
What does static variable mean in c?
192.
What are the different storage classes in C?
193.
What is hashing in C language?
194.
What is page thrashing?
195.
What is the benefit of using #define to declare a constant?
196.
How can I search for data in a linked list?
197.
When should a type cast be used?
198.
What is a null pointer in C?
199.
What is the stack in C?
200.
What is Preprocessor in C?
201.
What is the heap in C?
202.
What is the purpose of realloc( )?
203.
What is the purpose of main( ) function?
204.
What is the benefit of using const for declaring constants?
205.
What is the easiest sorting method to use?
206.
What is a const pointer in C?
207.
What is a pragma in C?
208.
What is #line used for?
209.
What is the difference between far and near in C?
210.
What is a method in C?
211.
Are pointers integers in C?
212.
How do you redirect a standard stream?
213.
What is indirection in C?
214.
What is an lvalue in C?
215.
Array is an lvalue or not?
216.
What is a void pointer in C?
217.
What is a pointer variable in C language?
218.
What is a static function in C?
219.
What is a pointer value and address in C?
220.
How do we print only part of a string in C?
221.
What is C language?
222.
What is Duffs Device?
223.
Here is a good puzzle: how do you write a program which produces its own source code as output?
224.
Suggesting that there can be 62 seconds in a minute?
225.
Was 2000 a leap year?
226.
How can I find the day of the week given the date?
227.
What is hashing in C?
228.
I need a sort of an approximate strcmp routine ...
229.
What is C Programing language?
230.
How can I call FORTRAN?
231.
What is assert and when would I use it?
232.
Why doesnt C have nested functions?
233.
Does C have an equivalent to Pascals with statement?
234.
If the assignment operator were ...
235.
Is C a great language, or what?
236.
Does C have circular shift operators?
237.
There seem to be a few missing operators ...
238.
Why isnt there a numbered, multi-level break statement to break out
239.
Why dont C comments nest?
240.
Are the outer parentheses in return statements really optional?
241.
Is there a way to have non-constant case labels (i.e. ranges or arbitrary expressions)?
242.
Is there a way to switch on strings?
243.
Which is more efficient, a switch statement or an if else chain?
244.
How can I swap two values without using a temporary?
245.
People claim that optimizing compilers are good and that we no longer have to write things in assembler for speed
246.
I have been replacing multiplications and divisions with shift operators, because shifting is more efficient.
247.
Are pointers really faster than arrays?
248.
What is the best way of making my program efficient?
249.
What is the most efficient way to count the number of bits which are set in an integer?
250.
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?
251.
How can I convert integers to binary or hexadecimal?
252.
How do I swap bytes?
253.
How can I determine whether a machines byte order is big-endian or little-endian?
254.
How can I implement sets or arrays of bits?
255.
How can I manipulate individual bits?
256.
If I have a char * variable pointing to the name of a function ...
257.
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
258.
What is the right way to use errno?
259.
What is a good data structure to use for storing lines of text?
260.
How can I return multiple values from a function?
261.
Why isnt any of this standardized in C? Any real program has to do some of these things.
262.
But I cant use all these nonstandard, system-dependent functions, because my program has to be ANSI compatible!
263.
What are near and far pointers?
264.
I am trying to compile this program
265.
How can I ensure that integer arithmetic doesnt overflow?
266.
How can I handle floating-point exceptions gracefully?
267.
How can I trap or ignore keyboard interrupts like control-C?
268.
How can I implement a delay, or time a users response, with sub-second resolution?
269.
How can I read in an object file and jump to locations in it?
270.
Is exit(status) truly equivalent to returning the same status from main?
271.
How can I open files mentioned on the command line, and parse option flags?
272.
How can a process change an environment variable in its caller?
273.
How can I automatically locate a programs configuration files in the same directory as the executable?
274.
How can my program discover the complete pathname to the executable from which it was invoked?
275.
How can I invoke another program or command and trap its output?
276.
How do I get an accurate error status return from system on MS-DOS?
277.
How can I call system when parameters (filenames, etc.) of the executed command arent known until run time?
278.
How can I invoke another program (a standalone executable, or an operating system command) from within a C program?
279.
How can I do PEEK and POKE in C?
280.
I thought that using large model meant that I could use more than 64K of data!
281.
How can I allocate arrays or structures bigger than 64K?
282.
How can I find out how much memory is available?
283.
How do I create a directory? How do I remove a directory (and its contents)?
284.
How can I read a directory in a C program?
285.
How can I find out how much free space is available on disk?
286.
How can I increase the allowable number of simultaneously open files?
287.
fopen isnt letting me open files like "$HOME/.profile" and "~/.myrcfile".
288.
Why cant I open a file by its explicit path?
289.
How do I copy files?
290.
How can I delete a file?
291.
How can I recover the file name given an open stream or file descriptor?
292.
ow can I insert or delete a line (or record) in the middle of a file?
293.
How can I find the modification date and time of a file?
294.
How can I find out the size of a file, prior to reading it in?
295.
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
296.
How can I send mail from within a C program?
297.
How can I do graphics in C?
298.
How can I access an I O board directly?
299.
How do I send escape sequences to control a terminal or other device?
300.
How can I direct output to the printer?
301.
How can I do serial comm port I O?
302.
How do I read the arrow keys? What about function keys?
303.
How can I make it pause before closing the program output window?
304.
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
305.
How can I find out if there are characters available for reading?
306.
I need code to parse and evaluate expressions.
307.
Dont ANSI function prototypes render lint obsolete?
308.
Where can I get an ANSI-compatible lint?
309.
How can I shut off the warning ...
310.
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
311.
People always say that good style is important
312.
What is Hungarian Notation? Is it worthwhile?
313.
Should I use symbolic names like TRUE and FALSE for Boolean constants, or plain 1 and 0?
314.
If NULL and 0 are equivalent as null pointer constants, which should I use?
315.
I came across some code that puts a (void) cast before each call to printf. Why?
316.
I have seen function declarations that look like this
317.
Why do some people write if(0 == x) instead of if(x == 0)?
318.
Here is a neat trick for checking whether two strings are equal
319.
How should functions be apportioned among source files?
320.
What is the best style for code layout in C?
321.
Why does this code crash?
322.
This program runs perfectly on one machine ...
323.
I have a program that seems to run correctly
324.
This program crashes before it even runs!
325.
Why isnt my procedure call working? The compiler seems to skip right over it
326.
I am getting baffling syntax errors which make no sense at all
327.
Why is this loop always executing once?
328.
How can I call a function with an argument list built up at run time?
329.
I cant get va_arg to pull in an argument of type pointer-to-function.
330.
I have a varargs function which accepts a float parameter
331.
My compiler isnt letting me declare a function
332.
How can I discover how many arguments a function was actually called with?
333.
How can I write a function analogous to scanf
334.
How can I write a function that takes a format string and a variable number of arguments
335.
I had a frustrating problem which turned out to be caused by the line
336.
How can f be used for both float and double arguments in printf? Are not they different types?
337.
I heard that you have to include stdio.h before calling printf. Why?
338.
I am having trouble with a Turbo C program which crashes
339.
What is a good way to implement complex numbers in C?
340.
The predefined constant M_PI seems to be missing from my machines copy of math.h.
341.
Why does not C have an exponentiation operator?
342.
How do I round numbers?
343.
I am sure I have got the trig functions declared correctly, but they are still giving me wrong answers.
344.
My floating-point calculations are acting strangely and giving me different answers on different machines.
345.
I am trying to do some simple trig, and I am #including , but the linker keeps complaining that functions like sin and cos are undefined
346.
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
347.
What does it mean when the linker says that _end is undefined?
348.
What is the difference between memcpy and memmove?
349.
How can I generate floating-point random numbers?
350.
How can I retHow can I return a sequence of random numbers which dont repeat at all?
351.
How can I get random integers in a certain range?
352.
Did C have any Year 2000 problems?
353.
How can I sort more data than will fit in memory?
354.
How can I sort a linked list?
355.
How can I get the current date or time of day in a C program?
356.
How can I split up a string into whitespace-separated fields?
357.
Why do some versions of toupper act strangely if given an upper-case letter?
358.
How do I convert a string to all upper or lower case?
359.
why isnt it being handled properly?
360.
How can I read/write structures from/to data files?
361.
How can I change their mode to binary?
362.
What is the difference between text and binary I/O?
363.
How can I read a binary data file properly?
364.
How can I get back to the interactive keyboard if stdin is redirected?
365.
Once I have used freopen, how can I get the original stdout (or stdin) back?
366.
How can I recover the file name given an open stream?
367.
How can I insert or delete a line (or record) in the middle of a file?
368.
If fflush wont work, what can I use to flush input?
369.
Why does everyone say not to use gets?
370.
What is the deal on sprintfs return value?
371.
Why does everyone say not to use scanf? What should I use instead?
372.
How can I read data from data files with particular formats?
373.
Why doesnt that code work?
374.
Why doesnt this code work?
375.
Why does the call char scanf work?
376.
Why doesnt the call scanf work?
377.
Why doesnt long int work?
378.
What is wrong with this code?
379.
What does the message "Automatic aggregate intialization is an ANSI feature" mean?
380.
What was noalias and what ever happened to it?
381.
What should malloc0 do? Return a null pointer or a pointer to 0 bytes?
382.
What are pragmas and what are they good for?
383.
What is the correct declaration of main?
384.
Can you mix old-style and new-style function syntax?
385.
What is the ANSI C Standard?
386.
How can I list all of the predefined identifiers?
387.
How can I use a preprocessorif expression to ?
388.
Is there anything like an ifdef for typedefs?
389.
What is the difference between #include <> and #include?
390.
What are the complete rules for header file searching?
391.
What is the right type to use for Boolean values in C? Is there a standard type? Should I use #defines or enums for the true and false values?
392.
Why does not
strcat(string, "!");
work?
393.
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
394.
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
395.
How can I dynamically allocate arrays?
396.
What is wrong with this initialization?
397.
How can this be legal C?
398.
Is a pointer a kind of array?
399.
Why ca not I do something like this?
400.
Is NULL valid for pointers to functions?
401.
How do I get a null pointer in my programs?
402.
What is this infamous null pointer, anyway?
403.
What is the total generic pointer type?
404.
Can I initialize unions?
405.
What are pointers really good for, anyway?
406.
Are enumerations really portable?
407.
C is not C++. Typedef names are not automatically generated
408.
What is the auto keyword good for?
409.
What is wrong with this declaration?
410.
Linked Lists -- Can you tell me how to check whether a linked list is circular?
411.
What does static variable mean in c?
412.
What are the different storage classes in C?
413.
What is hashing in C language?
414.
What is page thrashing?
415.
What is the benefit of using #define to declare a constant?
416.
How can I search for data in a linked list?
417.
When should a type cast be used?
418.
What is a null pointer in C?
419.
What is the stack in C?
420.
What is Preprocessor in C?
421.
What is the heap in C?
422.
What is the purpose of realloc( )?
423.
What is the purpose of main( ) function?
424.
What is the benefit of using const for declaring constants?
425.
What is the easiest sorting method to use?
426.
What is a const pointer in C?
427.
What is a pragma in C?
428.
What is #line used for?
429.
What is the difference between far and near in C?
430.
What is a method in C?
431.
Are pointers integers in C?
432.
How do you redirect a standard stream?
433.
What is indirection in C?
434.
What is an lvalue in C?
435.
Array is an lvalue or not?
436.
What is a void pointer in C?
437.
What is a pointer variable in C language?
438.
What is a static function in C?
439.
What is a pointer value and address in C?
440.
How do we print only part of a string in C?