Below are the list of some of the questions:
CFAQ:
http://c-faq.com
Some of the good links for Bit Manipulations:
1). Check if the number is power of two.
If we subtract 1 from a power of 2 what we get is 1s till the last unset bit and if we apply Bitwise AND operator we should get only zeros.
bool
isPowerOfTwo (
int
x)
{
return
x && (!(x&(x-1)));
}
2). Check if he number is even of Add using Bitwise operator:
The idea is to check whether the last bit of the number is set or not. If the last bit is set then the number is odd, otherwise even.
A). bitwise XOR Operation of the Number by 1 increment the value of the number by 1 if the number is even otherwise it decrements the value of the number by 1 if the value is odd.
bool
isEven(
int
n)
{
if
(n ^ 1 == n + 1)
return
true
;
else
return
false
;
}
B). Biwise And
bool
isEven(
int
n)
{
return
(!(n & 1));
}
c
). W know bitwise OR Operation of the Number by 1 increment
the value of the number by 1 if the number is even otherwise
it will remain unchanged.
bool
isEven(
int
n)
{
if
((n | 1) > n)
return
true
;
else
return
false
;
}
3).
Strings
Pointers
- Implementing system calls by yourself (sizeof, strcpy, strcmp etc)
- Implement your own sizeof and explain
Function Pointers
Structures/Unions/Bit fields/ Structure padding
Memory allocations and APIs (Malloc/calloc/realloc/heap)
- What is the point of using malloc(0)?
Various Keyword (Static, Volatile etc)
- Can static variables be declared in a header file?
- Can a variable be both const and volatile?
Make Files
Libraries (Static/Dynamic)
GCC Flags
Some popular questions:
- Difference between malloc and new?
- How will you design interface between two modules?
- Where variables sits In memory
- Diff between Vector and list .
- Volatile keyword
- Diff between Structure and union
- How to get size for union and structure
- Memory allocation in c
- Heap or variable which memory is fast
- Diff between link list and and vector
- Bit field, how these stored in memory
- Big endian and little endian
- If 1000 of integer linklist and array is present which would be faster and why
- Synchronisation in thread
- Diff in mutex and binary semaphore
- C memory management
- C Storage class
- Gdb
- Binary search
- Multi dimensional array
- IPC mechanism
- Which storage class is fast
- Write your own strtok function where each call return one token separated by delimiter passed in the string passed.
- Reverse string in place.
What are different gcc compiler options to secure your code.
How malloc works behind the scene.
How can you protect the same.
What is memory corruption. Different types.
- How printf works and write your own printf which can print all basic data type of c.
- What is the security issue with printf.
- Difference between strlcpy and strncpy. What is the security issue with this.
- Check for Balanced parenthesis.
- using Stack method how you will implement stack and what are different ways.
-above algo using lot of memory. now implement same using minimal use of memory.