Top 50 C, C++ Interview Questions asked in
Interviews!
- What does static variable mean?
- What is a pointer?
- What is a structure?
- What are enumerations?
- Describe about storage allocation and scope of global, extern, static, local and register variables?
- What are register variables? What are the advantage of using register variables?
- What is difference between Structure and Unions?
- What the advantages of using Unions?
- What are the advantages of using pointers in a program?
- What is the difference between Strings and Arrays?
- In a header file whether functions are declared or defined?
- What is a far pointer? where we use it?
- How will you declare an array of three function pointers where each function receives two ints and returns a float?
- What is a NULL Pointer? Whether it is same as an uninitialized pointer?
- What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
- What does the error ‘Null Pointer Assignment’ mean and what causes this error?
- What is near, far and huge pointers? How many bytes are occupied by them?
- How would you obtain segment and offset addresses from a far address of a memory location?
- If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
- Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
- What are bit fields? What is the use of bit fields in a Structure declaration?
- To which numbering system can the binary number 1101100100111100 be easily converted to?
- Which bit wise operator is suitable for checking whether a particular bit is on or off?
- Which bit wise operator is suitable for turning off a particular bit in a number?
- Which bit wise operator is suitable for putting on a particular bit in a number?
- Which bit wise operator is suitable for checking whether a particular bit is on or off?
- Which header file should you include if you are to develop a function which can accept variable number of arguments?
- Can you write a function similar to printf()?
- How can a called function determine the number of arguments that have been passed to it?
- Can there be at least some solution to determine the number of arguments passed to a variable argument list function?
- How would you use the functions sin(), pow(), sqrt()?
- How would you use the functions memcpy(), memset(), memmove()?
- How would you use the functions fseek(), freed(), fwrite() and ftell()?
- How would you obtain the current time and difference between two times?
- How would you use the functions randomize() and random()?
- How would you implement a substr() function that extracts a sub string from a given string?
- What is the difference between the functions rand(), random(), srand() and randomize()?
- What is the difference between the functions memmove() and memcpy()?
- How do you print a string on the printer?
- Can you use the function fprintf() to display the output on the screen?
- What is a linklist and why do we use it when we have arrays? - I feel the correct answer should be linklist is used in cases where you don’t know the memory required to store a data structure and need to allocate is dynamically on demand.
- How do you detect a loop in linked list?
- What is the difference between main() in C and main() in C++?
- what will be printed out when the following code is executed:
main()
{
printf("%x",-1<<4);
}
{
printf("%x",-1<<4);
}
- In header files whether functions are declared or defined?
- What are the differences between malloc() and calloc()?
- What are macros? What are the advantages and disadvantages?
- Difference between pass by reference and pass by value?
- What is static identifier?
- Where are the auto variables stored?