Saturday, January 5, 2008

Write a C program to count bits set in an integer?

What is a NULL pointer? How is it different from an unitialized pointer? How is a NULL pointer defined?

What does *p++ do? Does it increment p or the value pointed by p?

What is a null pointer assignment error?

How to reverse the bits in an interger?

Check if the 20th bit of a 32 bit integer is on or off?

How to reverse the odd bits of an integer?

How would you count the number of bits set in a floating point number?

Does an array always get converted to a pointer? What is the difference between arr and &arr? How does one declare a pointer to an entire array?

Is the cast to malloc() required at all?

What does malloc() , calloc(), realloc(), free() do? What are the common problems with malloc()? Is there a way to find out how much memory a pointer

What's the difference between const char *p, char * const p and const char * const p?

What is a void pointer? Why can't we perform arithmetic on a void * pointer?

What do Segmentation fault, access violation, core dump and Bus error mean?

What is the difference between an array of pointers and a pointer to an array?

What is a memory leak?

What are brk() and sbrk() used for? How are they different from malloc()?

What is a dangling pointer? What are reference counters with respect to pointers?

Is *(*(p+i)+j) is equivalent to p[i][j]? Is num[i] == i[num] == *(num + i) == *(i + num)?

What operations are valid on pointers? When does one get the Illegal use of pointer in function error?

What are near, far and huge pointers?

What is the difference between malloc() and calloc()?

Does C support function overloading?

Why is sizeof() an operator and not a function?

What is an opaque pointer?

What are the common causes of pointer bugs?

Does extern in a function declaration mean anything?

How can I return multiple values from a function?

What is the purpose of a function prototype?

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

Can we declare a function that can return a pointer to a function of the same type?

How can I write a function that takes a variable number of arguments? What are the limitations with this? What is vprintf()?

With respect to function parameter passing, what is the difference between call-by-value and call-by-reference? Which method does C use?

If I have the name of a function in the form of a string, how can I invoke that function?

What does the error, invalid redeclaration of a function mean?

How can I pass the variable argument list passed to one function to another function.

How do I pass a variable number of function pointers to a variable argument (va_arg) function?

Will C allow passing more or less arguments than required to a function.

Can we use variables inside a switch statement? Can we use floating point numbers? Can we use expressions?

Whats short-circuiting in C expressions?

Whats wrong with the expression a[i]=i++; ? Whats a sequence point?

Does the ?: (ternary operator) return a lvalue? How can I assign a value to the output of the ternary operator?

Is 5[array] the same as array[5]?

What are #pragmas?

What is the difference between if(0 == x) and if(x == 0)?

Should we use goto or not?

Is ++i really faster than i = i + 1?

What do lvalue and rvalue mean?

What does the term cast refer to? Why is it used?

What is the difference between a statement and a block?

Can comments be nested in C?

What is type checking?

Why can't you nest structure definitions?

What is the difference between the & and && operators and the | and || operators?

Is C case sensitive (ie: does C differentiate between upper and lower case letters)?

Can goto be used to jump across functions?

Whats wrong with #define myptr int *?

What purpose do #if, #else, #elif, #endif, #ifdef, #ifndef serve?

What is more efficient? A switch() or an if() else()?

Friday, January 4, 2008

If a is an array, is a++ valid?

How can we find out the length of an array dynamically in C?

Is char a[3] = "abc"; legal? What does it mean?

How to write functions which accept two-dimensional arrays when the width is not known before hand?

Can we determine the offset of a field within a structure and directly access that element?

What are bit fields in structures?

Why do structures get padded? Why does sizeof() return a larger size?

What is a union? Where does one use unions? What are the limitations of unions?

How does one use fread() and fwrite()? Can we read/write structures to/from files?

Can we pass constant values to functions which accept structure arguments?

Can we directly compare two structures using the == operator?

Can structures be assigned to variables and passed to and from functions?

Can structures be assigned to variables and passed to and from functions?

Define a macro called SQR which squares a number.

What is the token pasting operator and stringizing operator in C?

How can I write a macro which takes a variable number of arguments?

How should we write a multi-statement macro?

Is it acceptable to declare/define a variable in a C header?

Is there a limit on the number of characters in the name of a header file?

What should go in header files? How to prevent a header file being included twice? Whats wrong with including more headers?

What is the difference between enumeration variables and the preprocessor #defines?

How can I declare an array with only one element and still access elements beyond the first element (in a valid fashion)?

What is the difference between char *a and char a[]?

How to print the arguments recieved by main()?

Can main() be called recursively?

Is exit(status) equivalent to returning the same status from main()?

Whats the prototype of main()? Can main() return a structure?

What do setjmp() and longjump() functions do?

What does printf() return?

Can you compare two strings like string1==string2? Why do we need strcmp()?

What does alloca() do?

What do memcpy(), memchr(), memcmp(), memset(), strdup(), strncat(), strcmp(), strncmp(), strcpy(), strncpy(), strlen(), strchr(), strchr(), strpbrk()

What is assert() and when would I use it?

Why do some people put void cast before each call to printf()?

Why do we get the floating point formats not linked error?

How does the function strtok() work?

Why should one use strncpy() and not strcpy()? What are the problems with strncpy()?

How can I convert numbers to strings (the opposite of atoi)?

How can I specify a variable width in a scanf() format string?

How can I have a variable field width with printf?