Basic C Programming Exercises
Task 1: ASCII Art Stick Figure
Print a stick figure vertically:
#include <stdio.h>
int main() {
printf(" O \n");
printf("/|\\\n");
printf(" | \n");
return 0;
}
Print two stick figures vertically:
#include <stdio.h>
int main() {
printf(" O \n");
printf("/|\\\n&qu ...
Posted on Wed, 20 May 2026 07:47:21 +0000 by OldWolf
Queue Implementation in C Using Linked Lists
Queue Implementation in C Using Linked Lists
A queue is a fundamental data structure that follows the First-In-First-Out (FIFO) principle. This article presents a complete implementation of a queue using linked lists in C.
Header File - Queue.h
The header file contains function declarations and structure definitions for our queue implementat ...
Posted on Wed, 20 May 2026 05:05:19 +0000 by ziggs
Essential C Programming Concepts and Memory Management
Computer Storage Fundamentals
The smallest storage unit is a bit, holding either 0 or 1. The basic addressable unit is a byte (8 bits). Storage scales as:
1 KB = 1024 bytes
1 MB = 1024 KB
1 GB = 1024 MB
1 TB = 1024 GB
Numeric Representation
Computers store numbers using two's complement:
Signed types use the highest bit as sign (0=positive, ...
Posted on Wed, 20 May 2026 02:44:17 +0000 by Jami
Practical Exercises on Recursion and Iteration in C Programming
Printing Individual Digits of an Integer
The following recursive function separates and prints each digit of an unsigned integer.
#include <stdio.h>
void displayDigits(unsigned int num)
{
if (num > 9)
{
displayDigits(num / 10);
}
printf("%u ", num % 10);
}
int main()
{
unsigned int value = 0;
...
Posted on Tue, 19 May 2026 07:47:50 +0000 by CarbonCopy
Mastering Iteration Control Structures in C
Structured programming paradigms rely on three fundamantal control flows: sequence, selection, and iteration. While selection logic handles decision-making via statements like if and switch, repetitive tasks are managed through iteration constructs. C provides three primary keywords for looping: for, while, and do-while.
The For Loop
Among the ...
Posted on Tue, 19 May 2026 06:21:13 +0000 by kartul
Implementing Conditional Logic in C with If and Switch Statements
The 'if' StatementBranching logic is fundamental to controlling program execution flow. In C, the if statement allows code to execute specific blocks based on whether a condition evaluates to true or false. C interprets any non-zero value as true, while zero represents false.Single and Multi-Branch StructuresA basic branch involves one conditio ...
Posted on Mon, 18 May 2026 12:15:50 +0000 by jpadie
Comprehensive Guide to Eight Fundamental Sorting Algorithms
Sorting Fundamentals
Sorting is the process of arranging a sequence of records in either ascending or descending order based on one or more specified keys.
Stability: A sorting algorithm is considered stable if, for records with identical keys, their relative order remains unchanged after sorting. If the input has r[i] = r[j] with i < j, sta ...
Posted on Mon, 18 May 2026 09:06:09 +0000 by mvleus
Implementing Network I/O Multiplexing with Select and Epoll in C
Epoll Implementation
The following C program demonstrates a high-performance TCP server using the epoll mechanism on Linux. It utilizes non-blocking I/O and edge-triggered notifications to handle multiple concurrent connections efficiently.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#i ...
Posted on Mon, 18 May 2026 01:15:04 +0000 by Awesome Trinity
Implementing a Headed Circular Doubly Linked List in C
Structural DefinitionA headed circular doubly linked list utilizes a sentinel node (head) that acts as a starting point. Unlike a singly linked list, each node contains two pointers: prev pointing to the predecessor and next pointing to the successor. The sentinel node's prev points to the tail, and the tail's next points back to the sentinel, ...
Posted on Sun, 17 May 2026 16:15:51 +0000 by Wolverine68
Strategies for Error and Exception Management in C Programs
Understanding Runtime Anomalies in C
In C programming, ensuring robust and reliable applications often involves meticulously handling runtime anomalies. These are distinct from logical bugs present in the code itself. While a bug represents an unintended flaw in the program's design or implementation that leads to incorrect behavior, an excepti ...
Posted on Sun, 17 May 2026 11:56:58 +0000 by trev