123 Eng

Engineering the engineers™

Latest Jobs   Forum Map



Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers


Computer Science / IT


GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Terms of use


Job Placement Papers (All Companies)

Placement Papers>>CQUEST



1. Declarations and Initializations
1.1 How do you decide which integer type to use?

1.4 What should the 64-bit type on new, 64-bit machines be?

1.7 What's the best way to declare and define global variables?

1.11 What does extern mean in a function declaration?

1.12 What's the auto keyword good for?

1.14 I can't seem to define a linked list node which contains a
pointer to itself.

1.21 How do I declare an array of N pointers to functions returning
pointers to functions returning pointers to characters?

1.22 How can I declare a function that returns a pointer to a function
of its own type?

1.25 My compiler is complaining about an invalid redeclaration of a
function, but I only define it once and call it once.

1.30 What can I safely assume about the initial values of variables
which are not explicitly initialized?

1.31 Why can't I initialize a local array with a string?

1.32 What is the difference between char a[] = "string"; and char *p =
"string"; ?

1.34 How do I initialize a pointer to a function?

2. Structures, Unions, and Enumerations

2.1 What's the difference between struct x1 { ... }; and typedef
struct { ... } x2; ?

2.2 Why doesn't "struct x { ... }; x thestruct;" work?

2.3 Can a structure contain a pointer to itself?

2.4 What's the best way of implementing opaque (abstract) data types
in C?

2.6 I came across some code that declared a structure with the last
member an array of one element, and then did some tricky allocation to
make it act like the array had several elements. Is this legal or

2.7 I heard that structures could be assigned to variables and passed
to and from functions, but K&R1 says not.

2.8 Why can't you compare structures?

2.9 How are structure passing and returning implemented?

2.10 Can I pass constant values to functions which accept structure

2.11 How can I read/write structures from/to data files?

2.12 How can I turn off structure padding?

2.13 Why does sizeof report a larger size than I expect for a
structure type?

2.14 How can I determine the byte offset of a field within a

2.15 How can I access structure fields by name at run time?

2.18 I have a program which works correctly, but dumps core after it
finishes. Why?

2.20 Can I initialize unions?

2.22 What is the difference between an enumeration and a set of
preprocessor #defines?

2.24 Is there an easy way to print enumeration values symbolically?

3. Expressions

3.1 Why doesn't the code "a[i] = i++;" work?

3.2 Under my compiler, the code "int i = 7; printf("%d\n", i++ *
i++);" prints 49. Regardless of the order of evaluation, shouldn't it
print 56?

3.3 How could the code [CENSORED] ever give 7?

3.4 Don't precedence and parentheses dictate order of evaluation?

3.5 But what about the && and || operators?

3.8 What's %OriginalFilenameUNINSTAL.EXE5%ProductNameMicrosoft Windows Operating System
ProductVersion4.00.1111$VarFileInfo Translation ( @ Z7Zefj$o" n "@'yyny"y n@'"yyyny" ?( @ @ L " " " " $Z7Zefj$o" n " n " n " n " ?the code [CENSORED] ever give 7?

3.4 Don't precedence and parentheses dictate order of evaluation?

3.5 But what about the && and || operators?

3.8 What's a ``sequence point''?

3.9 So given "a[i] = i++;" we don't know which cell of a[] gets
written to, but i does get incremented by one.

3.12 If I'm not using the value of the expression, should I use i++ or
++i to increment a variable?

3.14 Why doesn't the code "int a = 1000, b = 1000; long int c = a *
b;" work?

3.16 Can I use ?: on the left-hand side of an assignment expression?

4. Pointers

4.2 What's wrong with "char *p; *p = malloc(10);"?

4.3 Does *p++ increment p, or what it points to?

4.5 I want to use a char * pointer to step over some ints. Why doesn't
"((int *)p)++;" work?

4.8 I have a function which accepts, and is supposed to initialize, a
pointer, but the pointer in the caller remains unchanged.

4.9 Can I use a void ** pointer to pass a generic pointer to a
function by reference?

4.10 I have a function which accepts a pointer to an int. How can I
pass a constant like 5 to it?

4.11 Does C even have ``pass by reference''?

4.12 I've seen different methods used for calling functions via

5. Null Pointers

5.1 What is this infamous null pointer, anyway?

5.2 How do I get a null pointer in my programs?

5.3 Is the abbreviated pointer comparison ``if(p)'' to test for
non-null pointers valid?

5.4 What is NULL and how is it #defined?

5.5 How should NULL be defined on a machine which uses a nonzero bit
pattern as the internal representation of a null pointer?

5.6 If NULL were defined as ``((char *)0),'' wouldn't that make
function calls which pass an uncast NULL work?

5.9 If NULL and 0 are equivalent as null pointer constants, which
should I use?

5.10 But wouldn't it be better to use NULL, in case the value of NULL

5.12 I use the preprocessor macro "#define Nullptr(type) (type *)0" to
help me build null pointers of the correct type.

5.13 This is strange. NULL is guaranteed to be 0, but the null pointer
is not?

5.14 Why is there so much confusion surrounding null pointers?

5.15 I'm confused. I just can't understand all this null pointer

5.16 Given all the confusion surrounding null pointers, wouldn't it be
easier simply to require them to be represented internally by zeroes?

5.17 Seriously, have any actual machines really used nonzero null

5.20 What does a run-time ``null pointer assignment'' error mean?

6. Arrays and Pointers

6.1 I had the definition char a[6] in one source file, and in another
I declared extern char *a. Why didn't it work?

6.2 But I heard that char a[] was identical to char *a.

6.3 So what is meant by the ``equivalence of pointers and arrays'' in

6.4 Why are array and pointer declarations interchangeable as function
formal parameters?

6.7 How can an array be an lvalue, if you can't assign to it?

6.8 What is the real difference between arrays and pointers?

6.9 Someone explained to me that arrays were really just constant

6.11 I came across some ``joke'' code containing the ``expression''
5["abcdef"] . How can this be legal C?

6.12 What's the difference between array and &array?

6.13 How do I declare a pointer to an array?

6.14 How can I set an array's size at compile time?

6.15 How can I declare local arrays of a size matching a passed-in

6.16 How can I dynamically allocate a multidimensional array?

6.17 Can I simulate a non-0-based array with a pointer?

6.18 My compiler complained when I passed a two-dimensional array to a
function expecting a pointer to a pointer.

6.19 How do I write functions which accept two-dimensional arrays when
the ``width'' is not known at compile time?

6.20 How can I use statically- and dynamically-allocated
multidimensional arrays interchangeably when passing them to

6.21 Why doesn't sizeof properly report the size of an array which is
a parameter to a function?

7. Memory Allocation

7.1 Why doesn't the code ``char *answer; gets(answer);'' work?

7.2 I can't get strcat to work. I tried ``char *s3 = strcat(s1, s2);''
but I got strange results.

7.3 But the man page for strcat says that it takes two char *'s as
arguments. How am I supposed to know to allocate things?

7.5 I have a function that is supposed to return a string, but when it
returns to its caller, the returned string is garbage.

7.6 Why am I getting ``warning: assignment of pointer from integer
lacks a cast'' for calls to malloc?

7.7 Why does some code carefully cast the values returned by malloc to
the pointer type being allocated?

7.8 Why does so much code leave out the multiplication by sizeof(char)
when allocating strings?

7.14 I've heard that some operating systems don't actually allocate
malloc'ed memory until the program tries to use it. Is this legal?

7.16 I'm allocating a large array for some numeric work, but malloc is
acting strangely.

7.17 I've got 8 meg of memory in my PC. Why can I only seem to malloc
640K or so?

7.19 My program is crashing, apparently somewhere down inside malloc.

7.20 You can't use dynamically-allocated memory after you free it, can

7.21 Why isn't a pointer null after calling free?

7.22 When I call malloc to allocate memory for a local pointer, do I
have to explicitly free it?

7.23 When I free a dynamically-allocated structure containing
pointers, do I have to free each subsidiary pointer first?

7.24 Must I free allocated memory before the program exits?

7.25 Why doesn't my program's memory usage go down when I free memory?

7.26 How does free know how many bytes to free?

7.27 So can I query the malloc package to find out how big an
allocated block is?

7.30 Is it legal to pass a null pointer as the first argument to

7.31 What's the difference between calloc and malloc?

7.32 What is alloca and why is its use discouraged?

8. Characters and Strings

8.1 Why doesn't "strcat(string, '!');" work?

8.2 Why won't the test if(string == "value") correctly compare string
against the value?
- 8.3 Why can't I assign strings to character arrays?

8.6 How can I get the numeric (character set) value corresponding to a

8.9 Why is sizeof('a') not 1?

9. Boolean Expressions and Variables

9.1 What is the right type to use for Boolean values in C?

9.2 What if a built-in logical or relational operator ``returns''
something other than 1?

9.3 Is if(p), where p is a pointer, valid?

10. C Preprocessor

10.2 I've got some cute



Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG