C Developer

C Developer Interview Questions and Answers for Freshers

Updated 11 Sep 2024

Q1. String Transformation Problem

Given a string (STR) of length N, you are tasked to create a new string through the following method:

Select the smallest character from the first K characters of STR, remove it fr...read more

Ans.

Given a string and an integer, create a new string by selecting the smallest character from the first K characters of the input string and repeating the process until the input string is empty.

  • Iterate through the input string, selecting the smallest character from the first K characters each time.

  • Remove the selected character from the input string and append it to the new string.

  • Continue this process until the input string is empty.

  • Return the final new string formed.

Q2. Merge K Sorted Arrays Problem Statement

Given 'K' different arrays that are individually sorted in ascending order, merge all these arrays into a single array that is also sorted in ascending order.

Input

The f...read more
Ans.

Merge K sorted arrays into a single sorted array.

  • Create a min heap to store the first element of each array along with the array index.

  • Pop the top element from the heap, add it to the result array, and push the next element from the same array back to the heap.

  • Continue this process until all elements are processed.

  • Time complexity can be optimized using a priority queue or merge sort technique.

Q3. Sort 0 1 2 Problem Statement

Given an integer array arr of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.

Input:

The first line contains an integer 'T' representing the number of...read more
Ans.

Sort an array of 0s, 1s, and 2s in linear time complexity.

  • Use three pointers to keep track of 0s, 1s, and 2s while iterating through the array.

  • Swap elements based on the values encountered to sort the array in-place.

  • Ensure to handle edge cases like all 0s, all 1s, and all 2s in the array.

Q4. Find Maximum Number by At-most K Swaps

Given an array of non-negative integers representing the digits of a number and an integer 'K', calculate the maximum possible number by swapping its digits up to 'K' time...read more

Ans.

Given an array of digits and an integer K, find the maximum number by swapping digits up to K times.

  • Sort the digits in non-increasing order to maximize the number.

  • Swap the digits to achieve the maximum number within the given number of swaps.

  • Handle cases where there are repeating digits and leading zeros.

Are these interview questions helpful?

Q5. BST Node Deletion Problem

Given a binary search tree (BST) and a key value K, your task is to delete the node with value K. It is guaranteed that a node with value K exists in the BST.

Explanation:

A binary sea...read more

Ans.

Delete a node with a given value from a binary search tree (BST).

  • Traverse the BST to find the node with the value K to be deleted.

  • Handle different cases like node with no children, one child, or two children.

  • Update the pointers of the parent node and child nodes accordingly.

  • Recursively delete the node and adjust the tree structure.

  • Return the root of the modified BST after deletion.

Q6. Move Zeroes to End Problem Statement

Given an unsorted array of integers, modify the array such that all the zeroes are moved to the end, while maintaining the order of non-zero elements as they appear original...read more

Ans.

Move all zeroes to the end of an unsorted array while maintaining the order of non-zero elements.

  • Iterate through the array and keep track of the index to place non-zero elements.

  • Once all non-zero elements are placed, fill the rest of the array with zeroes.

  • Ensure to maintain the relative order of non-zero elements.

  • Example: Input: [0, 1, -2, 3, 4, 0, 5, -27, 9, 0], Output: [1, -2, 3, 4, 5, -27, 9, 0, 0, 0]

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. Preorder Traversal of a BST Problem Statement

Given an array PREORDER representing the preorder traversal of a Binary Search Tree (BST) with N nodes, construct the original BST.

Each element in the given array ...read more

Ans.

Given a preorder traversal of a BST, construct the BST and return its inorder traversal.

  • Create a binary search tree from the preorder traversal array

  • Return the inorder traversal of the constructed BST

  • Ensure each element in the array is distinct

Q8. How to delete the middle element of a linked list?

Ans.

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 skip the middle element and connect the surrounding nodes

  • Free the memory of the deleted node

C Developer Jobs

C Developer 2-4 years
Capgemini Technology Services India Limited
3.7
Bangalore / Bengaluru
IDMC Developer 3-8 years
Wipro Limited
3.7
Chennai
SFDC LWC Developer 4-9 years
Tata Consultancy Services
3.7
Pune

Q9. Difference between multi-programming and multi-tasking.

Ans.

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

Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10.4k Interviews
3.5
 • 3.8k Interviews
3.9
 • 367 Interviews
3.9
 • 157 Interviews
3.1
 • 89 Interviews
4.4
 • 38 Interviews
View all

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

C Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter