Learning Outcomes:
● Basic Syntax & Structure: These problems teach foundational concepts of C
programming through conditional logic, loops, and functions.
● Pointers & Memory Management: Freshers will get hands-on experience with
pointer arithmetic, dynamic memory allocation, and handling strings.
● Structures & Unions: The exercises demonstrate how to model hardware-specific
structures and use unions to represent registers at multiple levels of granularity.
● Embedded C for SoC Testing: The exercises give practical exposure to the concept
of memory-mapped I/O, registers, and hardware peripherals that are critical for
embedded systems testing.
● Memory and Register Access: These problem statements reinforce how to work
with hardware registers, manipulate bits through masking and shifting, and
understand system endianness—a critical concept in hardware verification.
1. Basic Syntax & Structure
Problem 1: Calculator Using Conditional Statements
● Objective: Implement a basic calculator in C that performs addition, subtraction,
multiplication, and division using if, else, and switch statements.
● Task: Write a program that takes two integers and an operator (+, -, *, /) as input
and returns the result.
Problem 2: Fibonacci Sequence Using Loops
● Objective: Generate the first N numbers of the Fibonacci sequence using both for
and while loops.
● Task: Implement a program that prints the Fibonacci series up to a given number
using for and while loops for comparison.
Problem 3: Factorial Using Functions
● Objective: Write a function int factorial(int n) to compute the factorial of a
number using recursion.
● Task: Implement this function and test it with several input values.
2. Pointers and Memory Management
Problem 4: Swapping Two Numbers Using Pointers
● Objective: Use pointers to swap the values of two variables.
● Task: Write a function void swap(int *a, int *b) that takes two integer
pointers as arguments and swaps their values.
Problem 5: Dynamic Array Allocation
● Objective: Use malloc and free to create a dynamic array that stores N integers.
● Task: Implement a program that allocates memory for an array of N integers, takes N
inputs from the user, and prints the array. Then, free the allocated memory.
Problem 6: String Manipulation Using Pointers
● Objective: Reverse a string using pointers.
● Task: Write a function void reverse(char *str) that reverses the input string
using only pointer arithmetic.
3. Structures & Unions
Problem 7: Employee Record Using Structures
● Objective: Define and use a structure to store an employee’s information (ID, name,
salary).
● Task: Write a program to input and display details of N employees using an array of
structures.
Problem 8: Register Modeling Using Bit-fields
● Objective: Use bit-fields in a structure to model a hardware register with individual
control bits.
● Task: Define a structure with bit-fields to represent an 8-bit control register. Set, clear,
and read individual bits.
Problem 9: Union for Hardware Representation
● Objective: Use a union to represent a hardware register that can be accessed as
both a full 32-bit word and as individual 8-bit bytes.
● Task: Define a union that allows access to a 32-bit register as four 8-bit bytes, then
write a program to demonstrate reading and writing using both methods.
4. Embedded C for SoC Testing
Problem 10: Memory-Mapped I/O Simulation
● Objective: Simulate accessing a memory-mapped I/O register using pointers.
● Task: Define a #define BASE_ADDRESS 0x10000000 for a memory-mapped
register. Write a program that simulates writing a value to this register and reading it
back.
Problem 11: Register Read/Write with Masking
● Objective: Read from and write to specific bits of a memory-mapped control register.
● Task: Write a program that sets, clears, and reads specific bits of a simulated 32-bit
register. Use masking and shifting techniques to modify bits 3 and 7 without affecting
the others.
Problem 12: Accessing SoC Peripheral Registers
● Objective: Simulate interfacing with a UART (Universal Asynchronous
Receiver-Transmitter) register in SoC.
● Task: Define the necessary control and data registers for a UART peripheral (use
fictitious register addresses). Write a program to simulate writing a character to the
UART transmit register and reading a character from the UART receive register.
5. Memory and Register Access
Problem 13: Register Access via Pointers
● Objective: Simulate accessing a hardware register using pointers and modifying
specific bits.
● Task: Use a pointer to access a memory-mapped register and modify bits 0, 2, and 5.
Demonstrate writing and reading from the register.
Problem 14: Endianness Check
● Objective: Write a program to check the endianness of your system.
● Task: Write a function void check_endianness() that determines if the system
is big-endian or little-endian by checking the byte order of a multi-byte integer.
Problem 15: Endianness Conversion
● Objective: Implement a function to convert a 32-bit integer from big-endian to
little-endian and vice versa.
● Task: Write a function uint32_t convert_endianness(uint32_t num) that
converts between endianness formats, and test it with multiple inputs.