C Developer
50+ C Developer Interview Questions and Answers
You have been given ‘K’ different arrays/lists, which are sorted individually (in ascending order). You need to merge all the given arrays/list such that the output array/list should be sor...read more
Given a string (STR) of length N, you have to create a new string by performing the following operation:
Take the smallest character from the first 'K' characters of STR, remove it from STR...read more
C Developer Interview Questions and Answers for Freshers
You have been given an array/list 'PREORDER' representing the preorder traversal of a BST with 'N' nodes. All the elements in the given array have distinct values.
Your task is to con...read more
You have been given an integer array/list(ARR) of size 'N'. It only contains 0s, 1s and 2s. Write a solution to sort this array/list.
Note :
Try to solve the problem in 'Single Scan'. ' Single Scan' r...read more
You are given a binary search tree (BST) and a key value 'K'. You need to delete the node with value 'K'. It is guaranteed that a node has the value 'K'.
A binary search tree (BST), also called an ord...read more
You are given an array of 'N' non-negative integers, representing the digits of a number, and an integer 'K'. Your task is to find the maximum possible numbe...read more
Share interview questions and help millions of jobseekers 🌟
Given an unsorted array of integers, you have to move the array elements in a way such that all the zeroes are transferred to the end, and all the non-zero elements are moved to the front. The...read more
What is dynamic memory allocation in C?
C Developer Jobs
What is a zombie process?
Q10. what are processes and threads memory is allocated to what process or threads? what is mutex and semaphore how many threads/process can you launch at a time what is meaning of core in 4-core system what is cont...
read moreProcesses and threads are units of execution in a computer system. Memory is allocated to processes. Mutex and semaphore are synchronization mechanisms. Core refers to a processing unit in a multi-core system. Context switching is the process of switching between different processes or threads.
Processes are independent units of execution with their own memory space and resources.
Threads are lightweight units of execution within a process, sharing the same memory space.
Memory ...read more
Q11. Const pointer and pointer to const Join in Multithreading
Const pointer and pointer to const in multithreading
A const pointer cannot change the memory address it points to, but can change the value at that address
A pointer to const can change the memory address it points to, but cannot change the value at that address
In multithreading, const pointers can be used to ensure thread safety by preventing multiple threads from modifying the same memory location
Difference between structure and union
Q13. Time complexity of any sorting algorithm. Types of trees and linked list. How to achieve the concept of linked list in c++?
Sorting algorithm time complexity, types of trees and linked list, and implementing linked list in C++.
Sorting algorithms have different time complexities, such as O(n^2) for bubble sort and O(n log n) for quicksort.
Trees include binary, AVL, and red-black trees, among others.
Linked lists are a data structure where each element points to the next one, such as singly and doubly linked lists.
In C++, linked lists can be implemented using pointers and dynamic memory allocation.
Q14. Constants in C, Classes and object oriented programing system concepts in c++
Constants in C and OOP concepts in C++
Constants in C are variables whose value cannot be changed during program execution
Classes in C++ are user-defined data types that encapsulate data and functions
Object-oriented programming in C++ involves the use of classes, objects, inheritance, and polymorphism
What is IPC?
Convert Big Endian to Little Endian
Q17. Why we use join in Multithreading
Join is used to wait for a thread to finish execution before continuing with the main thread.
Join ensures that all the threads finish their execution before the main thread exits.
It is used to avoid race conditions and deadlocks.
Join can be used with detach to ensure that the thread is not left running in the background.
Example: Joining a thread that performs a time-consuming task before continuing with the main thread.
Example: Joining multiple threads to ensure that all the ...read more
Q18. What is class and objects in c++?
Class is a blueprint for creating objects. Objects are instances of a class with their own set of properties and methods.
Classes define the properties and methods that objects will have
Objects are created from a class using the 'new' keyword
Objects can interact with each other through their methods and properties
Example: class Car { int speed; void accelerate(); }; Car myCar; myCar.accelerate();
Example: class Person { string name; int age; void sayHello(); }; Person john; joh...read more
Q19. How to create thread, what is POSIX library? How many parameters we pass while creating thread.
Creating threads using POSIX library and passing parameters.
POSIX library provides functions for creating and managing threads in C++.
To create a thread, we use the pthread_create() function.
The function takes four parameters: a pointer to a pthread_t object, thread attributes, a function pointer to the thread function, and a void pointer to the thread function's argument.
Example: pthread_t thread; pthread_create(&thread, NULL, myThreadFunction, (void*)myArgument);
Q20. Scope of logic for functions, if blocks, loops, case structures.
Functions, if blocks, loops, and case structures have a wide scope of logic in C development.
Functions allow for modular and reusable code.
If blocks provide conditional logic.
Loops allow for repetitive tasks.
Case structures provide a way to handle multiple conditions.
All of these structures can be combined to create complex logic.
Proper use of these structures can improve code readability and maintainability.
Q21. Object oriented programming in c++
Object-oriented programming in C++ is a programming paradigm that uses objects to represent real-world entities.
Encapsulation, inheritance, and polymorphism are the three main pillars of OOP in C++.
Classes and objects are the building blocks of OOP in C++.
OOP in C++ allows for code reusability, modularity, and easier maintenance.
Example: A car can be represented as an object in C++ with properties like make, model, and color, and methods like start and stop.
Example: Inheritan...read more
Q22. How do you improve the code quality in the given piece of C++ code?
To improve code quality in C++ code, focus on readability, maintainability, performance, and adherence to best practices.
Use meaningful variable and function names to improve readability.
Break down complex functions into smaller, more manageable functions.
Follow coding standards and best practices such as using const-correctness, avoiding magic numbers, and using appropriate data structures.
Use comments and documentation to explain the purpose and functionality of the code.
Pe...read more
Q23. Runtime polymorphism and how it works vptr and vtable
Runtime polymorphism in C++ is achieved through virtual functions, vptr (virtual pointer), and vtable (virtual table).
Runtime polymorphism allows objects of different classes to be treated as objects of a common superclass.
Virtual functions are declared in a base class and overridden in derived classes to achieve polymorphism.
vptr is a pointer that points to the vtable of an object, allowing dynamic binding of virtual functions at runtime.
vtable is a table of function pointer...read more
Q24. Arrays in C, Public and private variables
Arrays in C are used to store multiple values of the same data type. Public and private variables are used for data encapsulation.
Arrays can be declared using square brackets, e.g. int arr[5];
Public variables can be accessed and modified by any part of the program, while private variables can only be accessed and modified within the same class or function.
Arrays of strings can be declared using char arr[5][10]; where 5 is the number of strings and 10 is the maximum length of ...read more
Q25. what is dynamic_cast where it can fail and what will happen in that case
dynamic_cast is a C++ operator used for safe downcasting of pointers and references in polymorphic classes.
dynamic_cast is used to safely downcast a pointer or reference from a base class to a derived class.
It can fail if the object being casted is not of the target type, in which case it returns a null pointer for pointers or throws a std::bad_cast exception for references.
Dynamic_cast can only be used with pointers or references to polymorphic classes (classes that have at ...read more
Q26. 3. Write a class to debit, credit and balance check functionalities
A class for debit, credit and balance check functionalities
Create a class with member variables for balance
Add member functions for debit, credit and balance check
Ensure proper validation and error handling
Consider using exception handling for errors
Q27. Memory management of variable and objects
Memory management involves allocating and deallocating memory for variables and objects.
Variables can be allocated on the stack or heap depending on their scope and lifetime.
Objects can be created using new operator and must be deleted using delete operator to avoid memory leaks.
Smart pointers like unique_ptr and shared_ptr can be used to manage object memory automatically.
Memory leaks can be avoided by properly managing object ownership and using RAII.
Memory fragmentation ca...read more
Q28. OOP'S concepts, reference vs pointer, malloc() vs new, PL SQL questions, simple snippets output
Questions related to OOP concepts, pointers, memory allocation, PL SQL, and code snippets.
OOP concepts include encapsulation, inheritance, and polymorphism.
Pointers hold memory addresses, while references are aliases for existing variables.
malloc() allocates memory on the heap, while new allocates memory on the heap and constructs an object.
PL SQL is a procedural language used for managing data in Oracle databases.
Code snippets can have varying outputs depending on the input ...read more
Q29. Puzzle 4 tier and one spare tier
The puzzle involves stacking 4 tiers of different sizes with one spare tier. The task is to find the minimum number of moves to stack them all.
Start by placing the largest tier at the bottom and the smallest at the top.
Move the spare tier to the desired position to stack the next tier.
Repeat until all tiers are stacked.
The minimum number of moves required is 15.
Q30. what's function pointer and what's it's signature
A function pointer is a variable that stores the address of a function. Its signature includes the return type and parameter types of the function.
Function pointers allow for dynamic function calls based on the stored address
Syntax: return_type (*pointer_name)(parameter_types)
Example: void (*funcPtr)(int) = &someFunction;
Q31. How to delete the middle element of a linked list?
To delete the middle element of a linked list, find the middle element using slow and fast pointers, then remove it by adjusting the pointers.
Use slow and fast pointers to find the middle element
Adjust pointers to remove the middle element
Update the links to maintain the integrity of the linked list
Q32. have you used any windows api's?
Yes, I have used Windows API's extensively in my previous projects.
I have used Windows API's for tasks such as creating windows, handling messages, and interacting with system resources.
Examples include using functions like CreateWindow, SendMessage, and ReadFile.
I have also worked with specific Windows API's like Winsock for networking and WinINet for internet-related tasks.
Q33. Difference between stack memory and heap memory
Stack memory is allocated automatically, while heap memory is allocated manually.
Stack memory is limited and has a fixed size, while heap memory is larger and can grow dynamically.
Stack memory is faster to access than heap memory.
Stack memory is used for local variables and function calls, while heap memory is used for dynamic memory allocation.
Examples of stack memory include function call stack and local variables, while examples of heap memory include dynamically allocated...read more
Q34. Copy one string to another without using any standard function
Use a loop to copy characters from one string to another
Create two character arrays to store the strings
Use a loop to iterate through each character of the source string and copy it to the destination string
Add a null terminator at the end of the destination string to mark the end of the copied string
Q35. What's Design pattern used in your project?
The design pattern used in my project is the Observer pattern.
Implemented to establish a one-to-many dependency between objects.
Allows multiple objects to listen and react to changes in a subject.
Promotes loose coupling between objects.
Example: Used to notify multiple UI components when a data model changes.
Q36. How to add external API to project
To add an external API to a project, you need to first obtain the API documentation and credentials.
Obtain API documentation and credentials
Integrate API into project using appropriate libraries or frameworks
Test API functionality and handle errors appropriately
Q37. Write a program to find the second largest element in an array.
Program to find the second largest element in an array
Iterate through the array to find the largest element
Then iterate again to find the second largest element
Handle edge cases like empty array or array with only one element
Q38. Overload + operator to add two complex numbers
Overload + operator to add two complex numbers in C++.
Define a class for complex numbers with real and imaginary parts.
Overload the + operator as a member function of the class.
Return a new complex number with the sum of real and imaginary parts.
Q39. Write code to delete node from linked list
To delete a node from a linked list, update the pointers of the previous node to skip the node to be deleted.
Traverse the linked list to find the node to be deleted
Update the pointers of the previous node to skip the node to be deleted
Free the memory allocated to the node to be deleted
Q40. Which version of c++ you use
I primarily use C++17, but I am familiar with earlier versions as well.
I am comfortable working with features introduced in C++17 such as structured bindings and constexpr if
I have experience with earlier versions like C++11 and C++14
I stay updated with the latest features and improvements in C++ standards
Q41. What's compile time polymorphism
Compile time polymorphism is achieved through function overloading and templates in C++.
Compile time polymorphism allows for different functions to be called based on the arguments provided at compile time.
Function overloading is a form of compile time polymorphism where multiple functions have the same name but different parameters.
Templates in C++ allow for generic programming and compile time polymorphism by creating functions or classes that can work with any data type.
Co...read more
Q42. Difference between multiprogramming and multitasking.
Multiprogramming involves running multiple programs on a single processor, while multitasking involves executing multiple tasks within a single program.
Multiprogramming allows multiple programs to be loaded into memory and executed concurrently, while multitasking involves switching between multiple tasks within a single program.
In multiprogramming, the operating system decides which program gets the processor's attention at any given time, while in multitasking, the program ...read more
Q43. Difference between multi-programming and multi-tasking.
Multi-programming involves running multiple programs on a single processor, while multi-tasking involves running multiple tasks within a single program.
Multi-programming allows multiple programs to be loaded into memory and executed concurrently, switching between them to utilize processor time efficiently.
Multi-tasking allows a single program to perform multiple tasks simultaneously, such as running multiple threads or processes within the program.
Examples of multi-programmi...read more
Q44. Bit shift 1 by 4 position from LSB
Bit shift 1 by 4 positions from LSB results in 16
Use the left shift operator (<<) to shift the bits by 4 positions
1 << 4 = 16
Q45. What is threads and programs
Threads are lightweight processes within a program that can run concurrently, allowing for multitasking. Programs are sets of instructions executed by a computer.
Threads are independent sequences of execution within a program.
Threads share the same memory space and resources, allowing for efficient communication and data sharing.
Programs are a collection of instructions that tell a computer how to perform a specific task.
Programs can be written in various programming language...read more
Q46. Find max occurance number in array
Find the number with the highest frequency in an array of strings.
Create a map to store the frequency of each number in the array.
Iterate through the array and update the frequency in the map.
Find the number with the highest frequency in the map.
Q47. what are oops pillers?
OOPs pillars are the four main principles of Object-Oriented Programming: Inheritance, Encapsulation, Abstraction, and Polymorphism.
Inheritance: Allows a class to inherit properties and behavior from another class.
Encapsulation: Bundling data and methods that operate on the data into a single unit.
Abstraction: Hiding the complex implementation details and showing only the necessary features of an object.
Polymorphism: Ability to present the same interface for different data ty...read more
Q48. what is union in c++
Union in C++ is a data structure that allows storing different data types in the same memory location.
Unions are similar to structures but all members share the same memory location.
Only one member of a union can be accessed at a time.
Unions are useful when you need to store different data types in the same memory space.
Example: union MyUnion { int i; float f; };
Example: MyUnion u; u.i = 10; // Accessing integer member of the union
Q49. what is weak pointer
Weak pointer is a type of smart pointer in C++ that does not control the lifetime of the object it points to.
Weak pointers are used to break circular references in shared pointers.
They do not increase the reference count of the object.
They are used in scenarios where the object may be deleted while there are still weak pointers pointing to it.
Q50. Explain Abstract design pattern.
Abstract design pattern is a way to define a blueprint for a group of objects with common characteristics.
It allows creating objects without specifying their concrete classes.
It promotes loose coupling between classes.
It is implemented using abstract classes and interfaces.
Example: Shape is an abstract class and Circle, Square, Triangle are its concrete subclasses.
Example: JDBC API uses abstract classes and interfaces to provide a common interface for different database vendo...read more
Interview Questions of Similar Designations
Top Interview Questions for C Developer Related Skills
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month