Basic C Coding Interview Questions
Bit Manipulation
1. Write a function to check if a given number is a power of two.
2. How do you count the number of set bits (1s) in an integer?
3. Write a program to toggle the nth bit of a number.
4. Write a function to swap two numbers without using a temporary variable.
5. Write a function to check if two integers have opposite signs.
6. Write a function to clear the rightmost set bit in a number.
7. How do you find the position of the only set bit in a number (assuming only one bit is set)?
8. Write a function to reverse the bits of a 32-bit integer.
9. Write a program to determine if a number is even or odd using bitwise operators.
10. Write a function to set the nth bit of a number.
Strings
1. Write a function to reverse a string in place.
2. Implement a function to check if a string is a palindrome.
3. Write a function to find the length of a string without using strlen.
4. Write a program to count the number of vowels and consonants in a string.
5. Implement your own version of strcpy.
6. Write a function to concatenate two strings without using strcat.
7. Write a program to remove all spaces from a string.
8. Implement a function to compare two strings (like strcmp).
9. Write a function to find the first non-repeating character in a string.
10. Write a function to check if two strings are anagrams.
Arrays
1. Write a function to find the largest and smallest elements in an array.
2. Implement a function to reverse an array.
3. Write a program to rotate an array to the left by d positions.
4. Write a function to find the missing number in an array of size n containing numbers from 1 to n+1.
5. Write a function to find the majority element in an array (appears more than n/2 times).
6. Implement binary search in a sorted array.
7. Write a function to find the maximum sum subarray (Kadane's Algorithm).
8. Write a program to remove duplicates from a sorted array.
9. Write a function to merge two sorted arrays into a sorted array.
10. Write a program to find the intersection of two arrays.
Linked Lists
1. Implement a singly linked list and write functions to insert a node at the beginning, end, and at a given po
2. Write a function to delete a node at a given position in a singly linked list.
3. Write a function to reverse a singly linked list.
4. Write a program to detect a loop in a linked list.
5. Write a function to find the middle element of a linked list.
6. Write a function to merge two sorted linked lists.
7. Write a function to remove duplicates from a sorted linked list.
8. Write a program to find the length of a linked list.
9. Write a function to detect and remove a loop in a linked list.
10. Write a program to implement a doubly linked list with insert and delete operations.