top of page

C Coding
Q&A: C Code
Q1: How do you find the size of an array in C? Q2: What is an array of pointers in C, and why is it useful? Q3: How can function pointers be used to trigger callbacks in C? Q4: How can we determine the size of a struct in C without using sizeof or any library macros? Q1: How do you find the size of an array in C? Use sizeof(arr) / sizeof(arr[0]), which divides the total memory by the size of one element to get the number of elements. #include <stdio.h> int main() { int arr[]
Ashok Kumar Kumawat
Apr 256 min read
Bubble Sort Concept
Bubble Sort repeatedly compares adjacent elements and swaps them if they are in the wrong order. After each pass, the largest element "bubbles up" to its correct position at the end. C Code Example #include <stdio.h> int main() { int arr[5] = {5, 3, 8, 4, 2}; // Example array int i, j, temp; int n = sizeof(array) / sizeof(array[0]); printf("Original array: "); for(i = 0; i < n; i++) { printf("%d ", arr[i]); } // Bubble Sort for(i = 0; i < n-1; i++) { for(j = 0; j < n-i-
Ashok Kumar Kumawat
Apr 252 min read
Storage Classes in Embedded C
Excellent, let’s now systematically cover Storage Classes in Embedded C with the structured breakdown you asked for. 1. Concept Overview Storage classes define scope, lifetime, and visibility of variables/functions. In embedded systems, this directly impacts memory usage, ISR behavior, and cross-module communication. The main storage classes are: auto → Default for local variables (stack-based, temporary). static → Persistent across function calls, limited scope if declared i
Ashok Kumar Kumawat
Apr 252 min read
Macros — Complete Guide for Embedded C
What is a Macro and How It Works at Compilation Stage Macros are handled by the C Preprocessor, which runs before the actual compilation begins. The compilation pipeline looks like this: Source.c → [Preprocessor] → Expanded.i → [Compiler] → object.o → [Linker] → final.elf The preprocessor performs textual substitution — it finds every macro usage and replaces it with the defined text, literally copy-pasting the expansion into the source before the compiler ever se
Ashok Kumar Kumawat
Feb 226 min read
Const and Pointer Qualifier Combinations in Embedded C
1. Concept Overview There are two main dimensions when combining const with pointers: Pointer to const integer → The integer value cannot be modified through this pointer, but the pointer itself can point elsewhere. Const pointer to integer → The pointer itself cannot change (fixed address), but the integer value it points to can be modified. Const pointer to const integer → Neither the pointer nor the value can be modified. 2. Embedded Industry Usage Pointer to const integer
Ashok Kumar Kumawat
Feb 223 min read
qualifiers interacting with storage classes
1. Concept Overview When qualifiers (const, volatile, signed, unsigned) are combined with storage classes (static, extern, register), they define scope, lifetime, mutability, and optimization rules. const volatile: Read-only from software, but value may change unexpectedly (common in hardware registers). static volatile: Persistent variable across function calls, but updated asynchronously (ISR flags). extern const: Shared constant across modules. extern volatile: Shared hard
Ashok Kumar Kumawat
Feb 82 min read
Data Type Qualifiers + Storage Class Interactions
Perfect, let’s extend our revision into Data Type Qualifiers + Storage Class Interactions. This is where embedded C really differs from desktop C, because qualifiers directly affect how the compiler generates code for hardware registers, ISRs, and memory-constrained systems. 1. Concept Overview Data type qualifiers: const, volatile, signed, unsigned, restrict (rare in embedded). Storage classes: static, extern, register, auto (default). Together, they define scope, lifetime,
Ashok Kumar Kumawat
Feb 82 min read
Data Type Qualifiers in Embedded C
1. Concept Overview Data type qualifiers modify the behavior of variables beyond their base type (int, char, etc.).Common qualifiers in C (and Embedded C) are: const → Read-only, cannot be modified after initialization. volatile → Tells the compiler the variable may change unexpectedly (e.g., hardware register, ISR). restrict (C99) → Optimizes pointer usage, rarely used in embedded. signed / unsigned → Defines whether a type can represent negative values. Default qualifiers:
Ashok Kumar Kumawat
Feb 82 min read
Data type in c
Alright Ashok, let’s dive into Data Types in Embedded C with the structured breakdown you asked for. I’ll keep this focused on embedded industry applications, resource-constrained environments, and safety-critical practices. 1. Concept Overview Data types define how the compiler interprets and allocates memory for variables. Common C types: char, int, short, long, float, double. In embedded systems, sizes are implementation-dependent (e.g., int may be 16-bit on some MCUs, 32-
Ashok Kumar Kumawat
Feb 82 min read


Microcontroller Memory Layout
In my corporate days, when we had to fit a complex automotive airbag driver into a tiny microcontroller with only 32KB of memory, we had to know exactly where every single bit lived. To understand how a C program is stored, you have to look at the Memory Layout. A microcontroller doesn't have a hard drive; it has Flash (ROM) and SRAM (RAM). 1. The "Storage" (Flash vs. RAM) When you turn the power off, your code stays on the chip. That’s because the actual instructions are
Ashok Kumar Kumawat
Feb 32 min read


The "Essential" Standard Functions
In a professional C or embedded environment, we call these Standard Library Functions. While you won't use printf inside a car's braking system (because there is no screen to print to!), you will use it constantly during testing and debugging on your PC or through a UART console. A close-up view of a microcontroller circuit board showcasing its intricate design. Here is the "Essential List" of functions every embedded engineer should know by heart. 1. Input / Output Function
Ashok Kumar Kumawat
Feb 32 min read
bottom of page