Skip to content

hexavik/C-Programming-Questions

Repository files navigation

C Programming Questions

Programming challenges for beginners and mid-level C programmers.

Arrays

Easy

  • Find the Max-Min in an Unsorted Array
  • Find the Missing Number in a 1 to 500 Sequence
  • Count Occurrences in a Sorted Array
  • Detect Duplicate Numbers
  • Rearrange Positive and Negative Numbers
  • Move Zeros to the Left
  • Rotate an Array Right
  • Check for Divisible Sum Pairs
  • Locate Target Sum Pairs

Medium

  • Remove Duplicate Without Libraries
  • Identify Multiple Duplicates
  • Find Array Leaders
  • Find the Equilibrium Index
  • Identify a Peak Element
  • Identify the Majority Element
  • Merge Sorted Arrays
  • Calculate Array Intersection
  • Retrieve k-th Max-Min Element
  • Find the Minimum Sum Subarray
  • Detect a Zero-Sum Subarray
  • Calculate the Product of an Array Except Self

Hard

  • Locate the Longest Consecutive Subsequence
  • Transform a Self-Referential Array
  • Implement Quicksort on an Array

Strings

Easy

  • Validate if a String is a Palindrome
  • Reverse a String Recursively
  • Count Character Occurrences in a String
  • Count Vowels and Consonants in a String
  • Verify a Pangram
  • Verify That a String Contains Only Numeric Characters
  • Check if Two Strings Are Anagrams
  • Find the First Unique Character in a String
  • Identify Duplicate Characters in a String
  • List Multiple Occurrences of Characters in a String

Medium

  • Encode a String Alphabetically
  • Convert a String to an Integer Without Built-In Functions
  • Reverse Words in a Sentence Without Libraries
  • Count Substring Occurrences in a String
  • Count Balanced Zero-One Substrings
  • Validate Balanced Parentheses in a String
  • Verify String Rotations
  • Find the Lexicographically Minimal String Rotation
  • Identify the Longest Substring Without Repeats
  • Evaluate Repeated Substring Patterns

Hard

  • Find the Longest Palindromic Substring
  • Minimize Palindromic Partitions
  • Evaluate String Interleaving
  • Generate All String Permutations

Structures and Unions

Easy

  • Calculate Student Average Marks
  • Manage Employee Addresses
  • Calculate a Book Price Discount
  • Calculate the Distance between 3D Points
  • Perform Time Operations Using Structures
  • Perform Complex Number Operations
  • Convert Color Systems (RGB to CMYK) Using Unions
  • Represent Error Codes Using Unions
  • Read File Attributes Into a Structure

Medium

  • Implement a Library Database System
  • Implement a Vehicle Extended Structure Using Unions
  • Implement a Student Linked List
  • Parse Commands
  • Create a Variable Data Type Array Using Unions
  • Calculate Data Differences
  • Implement Menu Items with Function Pointers in a Structure
  • Identify Network Packet Types Using Unions

Hard

  • Access a 32-Bit Value Using a Union
  • Convert a 4-Byte Value Using a Union
  • Convert an IP Address Using Structures and Unions
  • Represent an IP Address Using a Union
  • Perform Endianness Conversion Using a Union
  • Configure Device Settings Using Bitfields
  • Optimize Structure Memory Padding
  • Serialize a Data Packet

Bit Manipulations

Easy

  • Convert Decimal to Binary
  • Count Set Bits
  • Detect Power of Two
  • Determine if Two Integers Have Opposite Signs
  • Find the Parity of a Number
  • Isolate the Rightmost Set Bit
  • Toggle the 3rd and 5th Bits
  • Mask Certain Bits
  • Extract n Bits
  • Clear Bits from MSB to i

Medium

  • Find the Single Number in an Array
  • Find a Unique Number in an Array
  • Reverse Bits in a Byte
  • Rotate Bits
  • Swap Odd and Even Bits
  • Check for Alternate Bits
  • Check if a Number is a Multiple of 3
  • Count the Number of Flips to Convert A to B
  • Implement Bitwise Right Shift
  • Calculate a to the Power of b Using Bit Manipulation
  • Implement XOR without using the XOR operator
  • Set Bits Without Using Arithmetic Operations

Hard

  • Find Two Unique Numbers in an Array
  • Check if the Binary Representation of a Number is a Palindrome
  • Generate All Possible Combinations of n Bits

Pointers

Easy

  • Convert a String to Lowercase
  • Trim String Whitespace
  • Check if a String is a Palindrome
  • Check String Prefix
  • Swap Two Strings Using Pointers
  • Move a 2D Point
  • Calculate the Dot Product of Vectors
  • Find Data Type Size Without Using sizeof

Medium

  • Concatenate Strings Without a Library
  • Split a String into Halves
  • Find the First Non-Repeated Character
  • Count Array Elements Without a Loop
  • Rotate an Array by 'k' Elements
  • Segregate Even and Odd Numbers Using Pointers
  • Merge Two Sorted Arrays
  • Find Array Intersection
  • Find Common Elements in Sorted Arrays
  • Find Overlapping Elements in Arrays
  • Flatten a 2D Array to 1D
  • Find the Length of a Linked List
  • Check if Pointers Point to the Same Array

Hard

  • Implement a Custom memcpy Function
  • Implement a Custom strtok Function
  • Detect a Pointer Out of Bounds
  • Detect Memory Leaks

Memory Management

Easy

  • Implement a Custom strdup Function
  • Implement a Dynamic Array
  • Calculate a Memory Offset
  • Check Memory Alignment
  • Initialize a Memory Library
  • Log Memory Accesses

Medium

  • Detect Memory Leaks
  • Analyze the Memory Footprint
  • Report Memory Statistics
  • Detect a Stack Overflow
  • Implement a Memory Pool
  • Implement a Stack-Based Memory Allocator
  • Simulate Write-Once Memory
  • Serialize an Object
  • Inspect Heap Metadata
  • Detect Memory Fragmentation

Hard

  • Defragment Memory
  • Implement a Memory-Mapped Circular Buffer
  • Implement a Memory-Bound Priority Queue
  • Manage Memory Overlay
  • Implement a Segmented Memory Allocator
  • Implement a Slab Allocator
  • Simulate Virtual Memory
  • Simulate a Garbage Collector
  • Check Memory Safety

Linked Lists

Easy

  • Find the Length of a Linked List
  • Find the Middle Element
  • Reverse a Linked List
  • Reverse a Linked List (No Recursion)
  • Find the n-th Node from the End
  • Move the Last Element to the Front
  • Delete Alternate Nodes
  • Pairwise Swap Elements

Medium

  • Detect a Cycle in a Linked List
  • Merge Two Sorted Lists
  • Remove Duplicates (Unsorted List)
  • Remove Nodes of a Specific Value
  • Convert a Binary Number to an Integer
  • Segregate Even and Odd Nodes
  • Compare Strings as Linked Lists
  • Find the Intersection Point of Two Lists
  • Detect and Remove a Loop
  • Check if a Linked List is a Palindrome
  • Partition a Linked List Around a Value

Hard

  • Add Numbers Represented by Lists
  • Implement Merge Sort on a Linked List
  • Clone a Linked List with a Random Pointer
  • Flatten a Multi-level Linked List
  • Find the Common Ancestor in a Binary Tree Using a Doubly Linked List

Stacks and Queues

Easy

  • Check for Balanced Parentheses Using a Stack
  • Check if a String is a Palindrome Using a Stack
  • Implement a Circular Queue
  • Implement a Stack with a Get-Min Operation
  • Count Nested Statements Using a Stack
  • Implement a Queue-Based Logger

Medium

  • Implement a Stack-Based Calculator
  • Validate Expressions Using a Stack
  • Implement a Multi-Stack Array
  • Parse Commands Using a Stack or Queue
  • Implement a Queue-Based Cache
  • Generate Sequences Using a Queue
  • Filter Text Using a Queue
  • Implement a Priority Queue Using a Heap
  • Implement a Queue Supporting Two Priorities
  • Implement a String Message Queue
  • Implement Undo and Redo Using Stack
  • Log Function Calls Using a Stack

Hard

  • Implement a Queue Using Stacks
  • Sort a Stack
  • Perform Post-Order Traversal Using a Stack
  • Convert a Recursive Function to Iterative Using a Stack
  • Implement a Stack-Based Text Editor
  • Implement a Byte-Packing Stack
  • Implement Radix Sort Using a Queue

Searching

Easy

  • Search Sorted Array
  • Search Unsorted Array
  • Perform a Recusrive Binary Search
  • Perform a Sentinel Search
  • Perform a Jump Search
  • Count Occurrences of a Number
  • Find the First and Last Occurrences
  • Find Two Numbers That Sum to 'N'

Medium

  • Search an Unknown-Length Array
  • Find a Fixed Point
  • Find a Peak Element
  • Count Array Rotations
  • Perform an Interpolation Search
  • Perform an Exponential Search
  • Perform a Ternary Search
  • Find the Missing Number from '1' to 'n'
  • Find the Majority Element
  • Search a Nearly Sorted Array

Hard

  • Search a Sorted Rotated Array
  • Perform a Fibonacci Search
  • Find the Repeating and Missing Numbers
  • Find the Smallest Missing Numbers
  • Find the 'k'-th Max-Min Element
  • Search a Bitonic Array
  • Search a Sorted Matrix

Sorting

Easy

  • Implement Optimized Bubble Sort
  • Implement Gnome Sort
  • Implement Cocktail Sort
  • Implement Odd Even Sort
  • Implement Comb Sort
  • Implement Sleep Sort
  • Implement Bogo Sort
  • Implement Stooge Sort

Medium

  • Implement Cycle Sort
  • Implement Pancake Sort
  • Implement Pigeonhole Sort
  • Implement Counting Sort for Negative Numbers
  • Implement Bucket Sort
  • Implement Dynamic Gap Shell Sort
  • Sort a Linked List Using Insertion Sort
  • Implement Bead Sort
  • Implement Iterative Quick Sort
  • Implement Recursive Merge Sort
  • Implement In-Place Merge Sort
  • Implement Heap Sort with a Binary Max Heap

Hard

  • Implement Radix Sort for Floating-Point Numbers
  • Implement Bitonic Sort
  • Implement Patience Sort
  • Implement Permutation Sort
  • Implement Tim Sort

Linux Internals

Easy

  • Parse Command-Line Argument
  • Copy a File
  • Fetch CPU Information
  • Traverse a Filesystem Using opendir and readdir
  • Implement the chmod Command
  • Read a File in User-Space
  • Implement the tail Command

Medium

  • Implement a Custom ps Command
  • Implement Custom malloc and free
  • Fork and Wait for Processs
  • Create and Synchronize Threads
  • Access a File Using Mutexes
  • Implement a Simple Shell
  • Handle Signals with a Custom Handler
  • Implement the ping Command
  • Implement the whois Command
  • Implement the watch Command
  • Implement a CPU Scheduling Algorithm

Hard

  • Solve the Producer-Consumer Using Semaphores
  • Demonstrate the Priority Inversion Problem
  • Implement Priority Inversion Handling
  • Create a Custom Init Process
  • Communicate Between User-Space and Kernel-Space
  • Perform a Zero-Copy Data Transfer
  • Implement a Terminal Multiplexer

About

Curated list of problems to strengthen the C programming concepts along with some software engineering related modules like Linux fundamentals.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages