0% found this document useful (0 votes)
0 views

Programskkkmk

The document outlines various programming tasks related to preprocessor directives, structs, unions, and pointers in C. It includes exercises for defining macros, conditional compilation, and creating structs for different data types, as well as implementing unions for memory management. Each section provides specific programming challenges to enhance understanding of these concepts.

Uploaded by

captainlewisite
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Programskkkmk

The document outlines various programming tasks related to preprocessor directives, structs, unions, and pointers in C. It includes exercises for defining macros, conditional compilation, and creating structs for different data types, as well as implementing unions for memory management. Each section provides specific programming challenges to enhance understanding of these concepts.

Uploaded by

captainlewisite
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

‭Programs‬

‭Preprocessor Directives‬

‭1.‬ ‭Basic Macro Definition‬


‭Write a program using‬‭ #define‬‭to define a constant‬‭for PI and use it to‬
‭calculate the area of a circle.‬

‭2.‬ ‭Conditional Compilation with Debug Mode‬


‭Create a program where‬‭ #ifdef DEBUG‬‭is used to print‬‭debugging‬
‭information, and toggle between debug and release modes.‬

‭3.‬ ‭Function-Like Macros‬


‭Write a macro that swaps two variables of any data type and demonstrate‬
‭it in a program.‬

‭4.‬ ‭Macro for Array Size‬


#define‬‭to create a macro that calculates the‬‭size of an array.‬
‭Use‬‭

‭5.‬ ‭Macro for Maximum of Two Numbers‬


#define‬‭to find the maximum of‬‭two numbers.‬
‭Create a macro using‬‭

‭6.‬ ‭Macro for Square Calculation‬


‭Define a macro to calculate the square of a number and use it for different‬
‭data types.‬

##‬
‭7.‬ ‭Combining Tokens Using‬‭
##‬‭operator in‬
‭ rite a program that demonstrates token pasting using the‬‭
W
‭macros.‬

‭8.‬ ‭Stringification in Macros (‬‭


#‬‭)‬
#‬‭operator to stringify a token and demonstrate‬‭it in a program.‬
‭Use the‬‭
‭9.‬ ‭File Inclusion and Conditional Compilation‬
‭Use‬‭ #include‬ #ifndef‬
‭,‬‭ #endif‬‭to conditionally‬‭include header‬
‭, and‬‭
‭files based on a condition.‬

‭10.‬ ‭Multiple Inclusion Protection (‬‭


#pragma once‬
‭)‬
‭ emonstrate how‬‭
D #pragma once‬‭works to avoid multiple‬‭inclusions of the‬
‭same header file.‬

#if‬
‭11.‬‭Conditional Compilation with‬‭ #else‬
‭,‬‭ #endif‬
‭, and‬‭
#if‬
‭ rite a program that uses‬‭
W #else‬
‭,‬‭ #endif‬‭to‬‭control which parts‬
‭, and‬‭
‭of the code are compiled based on a defined constant.‬

‭12.‬ ‭Defining and Undefining Macros‬


‭Create a program that uses‬‭ #define‬‭and‬‭ #undef‬‭to define‬‭and undefine‬
‭a macro, showing how it affects the code.‬

‭13.‬ ‭Using the‬‭ __LINE__‬‭and‬‭ __FILE__‬‭Macros‬


‭Write a program that prints the current line number and file name using the‬
__LINE__‬‭and‬‭
‭ __FILE__‬‭macros.‬

‭14.‬ #error‬
‭Custom Error Messages with‬‭
#error‬‭to generate custom error‬‭messages‬
‭ emonstrate the use of‬‭
D
‭during compilation.‬

‭15.‬ __DATE__‬‭and‬‭
‭Predefined Macros like‬‭ __TIME__‬
__DATE__‬‭and‬
‭Write a program that prints the current date and time using‬‭
__TIME__‬
‭ ‭.‬

‭16.‬ #elif‬
‭Conditional Macro Expansion Using‬‭
#if‬
‭ se‬‭
U #elif‬
‭,‬‭ #endif‬‭to demonstrate conditional‬‭macro‬
‭, and‬‭
‭expansion for multiple cases.‬

‭17.‬ ‭Counting Occurrences in a String‬


‭Create a program that uses a function-like macro to count the occurrences‬
‭of a specific character in a string.‬
‭18.‬ ‭Recursive Macros‬
‭Write a program that demonstrates how to create recursive macros, such‬
‭as expanding nested macros.‬

‭19.‬ ‭Macro for Error Handling‬


‭Define a macro that prints error messages based on different error codes,‬
#define‬‭and conditional compilation.‬
‭using‬‭

‭20.‬ ‭Macro for Type Casting‬


‭Create a macro that typecasts a variable to a different type and‬
‭demonstrates its use in a mathematical operation.‬

‭21.‬ ‭Swap Two Variables Using a Macro Function‬


‭Define a macro‬‭ SWAP(x, y, type)‬‭that swaps two variables‬‭of any type‬
‭(int, float, etc.). Create a program where you demonstrate swapping‬
‭integers, floats, and characters using this macro.‬

‭22.‬ ‭Find the Maximum of Three Numbers‬


‭Create a macro‬‭MAX_OF_THREE(a, b, c)‬‭that returns‬‭the maximum of‬
‭three numbers. Use it to compare three integers and three floats in a‬
‭program.‬

‭23.‬ ‭Calculate the Absolute Value Using Macros‬


‭Write a macro‬‭ ABS(x)‬‭that computes the absolute value‬‭of a number. Test‬
‭it with both positive and negative integers and floating-point numbers to‬
‭ensure correctness.‬

‭24.‬ ‭Check if a Number is Even or Odd‬


‭Create a macro function‬‭ IS_EVEN(x)‬‭that returns true‬‭if the number is‬
‭even and false if odd. Use it to check multiple integers and display whether‬
‭they are even or odd.‬

‭25.‬ ‭Determine the Minimum of Two Numbers‬


‭Define a macro‬‭ MIN(a, b)‬‭that returns the smaller‬‭of two numbers. Use‬
‭this in a program to compare integers and floats.‬

‭26.‬ ‭Square of a Number Using a Macro Function‬


‭Write a macro‬‭SQUARE(x)‬‭that computes the square of‬‭a number. Use it in‬
‭a program to calculate the square of multiple integers and floats.‬
‭27.‬ ‭Macro for Cubing a Number‬
‭Define a macro‬‭ CUBE(x)‬‭that calculates the cube of‬‭a number.‬
‭Demonstrate it by calculating cubes of various integers and floating-point‬
‭numbers.‬

‭28.‬ ‭Check if a Number is Positive, Negative, or Zero‬


‭Create a macro‬‭ SIGN(x)‬‭that returns 1 if the number‬‭is positive, -1 if‬
‭negative, and 0 if it is zero. Test it with multiple input values (positive,‬
‭negative, and zero).‬

‭29.‬ ‭Convert Degrees to Radians‬


DEG_TO_RAD(deg)‬‭that converts an angle‬‭in degrees to‬
‭Write a macro‬‭
radians = degrees * (PI‬‭
r‭ adians using the formula‬‭ / 180)‬
‭. Test it‬
‭with multiple angles.‬

‭30.‬ ‭Macro for Clamping a Value‬


CLAMP(x, min, max)‬‭that restricts a‬‭value‬‭
‭Create a macro‬‭ x‬‭to stay‬
[min, max]‬
‭within the range‬‭ x‬‭is less than‬‭
‭. If‬‭ min‬ min‬
‭,‬‭it returns‬‭ x‬‭is‬
‭; if‬‭
g max‬
‭ reater than‬‭ max‬
‭, it returns‬‭ ‭. Test this with various‬‭numbers to ensure‬
‭the clamping works.‬

‭Struct Based Programs‬

‭Basic Struct Programs‬


‭1.‬ ‭Define a Simple Struct for a Point‬
Point‬‭to represent a point in 2D space‬‭with‬‭
‭Create a struct‬‭ x‬‭and‬‭
y‬
‭ oordinates. Write a program that initializes a‬‭
c Point‬‭and prints its‬
‭coordinates.‬
‭2.‬ ‭Struct for Student Information‬
‭Define a struct‬‭ Student‬‭with fields like‬‭name‬ roll_number‬
‭,‬‭ marks‬
‭,‬‭and‬‭ ‭.‬
‭Initialize a student and print their details.‬
‭3.‬ ‭Struct for Employee Details‬
Employee‬‭that holds fields like‬‭
‭Write a struct‬‭ employee_id‬ name‬
‭,‬‭ ‭, and‬
‭alary‬
s ‭. Initialize an employee and display the information.‬
‭4.‬ ‭Struct for Date Representation‬
‭Create a struct‬‭ Date‬‭with‬‭
day‬ month‬
‭,‬‭ year‬
‭, and‬‭ ‭. Write a program that‬
dd/mm/yyyy‬‭format.‬
i‭nitializes a date and prints it in‬‭
‭5.‬ ‭Struct for Complex Numbers‬
‭Define a struct‬‭ Complex‬‭that holds the real and imaginary‬‭parts of a‬
‭complex number. Write a program that initializes a complex number and‬
‭prints it.‬
‭6.‬ ‭Struct as Function Argument‬
Point‬‭struct as an argument‬‭and prints its‬
‭Write a function that takes a‬‭
Point‬‭and pass it to the function.‬
‭ oordinates. Create a‬‭
c
‭7.‬ ‭Array of Structs‬
Book‬‭with fields like‬‭
‭Create a struct‬‭ title‬ author‬
‭,‬‭ price‬
‭,‬‭and‬‭ ‭. Use an‬
‭ rray of‬‭
a Book‬‭structs to store information for multiple‬‭books and print the‬
‭details.‬
‭8.‬ ‭Struct with Nested Structs‬
‭Define a struct‬‭ Person‬‭that includes a nested struct‬‭ Date‬‭for the person's‬
‭birthdate. Initialize and print the person's name and birthdate.‬
‭9.‬ ‭Input Data for Structs‬
‭Write a program that takes user input for a‬‭ Student‬‭struct (e.g., name, roll‬
‭number, marks) and displays the information.‬
‭10.‬ ‭Struct for Time Representation‬
Time‬‭with‬‭
‭Create a struct‬‭ hours‬ minutes‬
‭,‬‭ seconds‬
‭, and‬‭ ‭.‬‭Write a‬
hh:mm:ss‬‭format.‬
‭program to initialize and display the time in‬‭

‭Slightly More Advanced Struct Programs‬

‭1.‬ ‭Struct for Handling Fractions‬


‭Define a struct‬‭ Fraction‬‭with‬‭numerator‬‭and‬‭ denominator‬ ‭.‬‭Write‬
‭functions to add, subtract, multiply, and divide two fractions.‬
‭2.‬ ‭Struct for Managing Bank Accounts‬
BankAccount‬‭with fields like‬‭
‭Create a struct‬‭ account_number‬ ‭,‬
‭alance‬
b account_holder_name‬
‭, and‬‭ ‭. Implement functions for‬
‭depositing and withdrawing money, updating the balance.‬
‭3.‬ ‭Struct for a Dynamic Array of Employees‬
‭Create an array of‬‭ Employee‬‭structs and allow the user to dynamically‬
‭add or remove employees. The program should also display the total‬
‭number of employees.‬
‭4.‬ ‭Struct for Distance Calculation‬
Point‬‭struct to calculate‬‭the Euclidean‬
‭Write a program that uses a‬‭
‭distance between two points in a 2D plane.‬
‭5.‬ ‭Struct for Managing Inventory‬
InventoryItem‬‭with fields like‬‭
‭Create a struct‬‭ item_code‬ item_name‬
‭,‬‭ ‭,‬
quantity‬
‭and‬‭ ‭. Implement functions to add and remove‬‭items from‬
i‭nventory and to search for an item by‬‭ item_code‬ ‭.‬
‭6.‬ ‭Struct for Polynomial Representation‬
‭Define a struct‬‭ PolynomialTerm‬‭with‬‭ coefficient‬‭and‬‭ exponent‬ ‭.‬
‭Write a program to add two polynomials represented as arrays of‬
PolynomialTerm‬‭structs.‬

‭7.‬ ‭Struct for Storing Vehicle Information‬
‭Create a struct‬‭ Vehicle‬‭with fields like‬‭
make‬ model‬
‭,‬‭ ‭,‬‭and‬‭year‬ ‭. Write a‬
‭program to store and display information for multiple vehicles and allow the‬
‭user to search for vehicles by year.‬
‭8.‬ ‭Struct for Managing Product Discounts‬
Product‬‭with fields like‬‭
‭Write a struct‬‭ product_name‬ price‬
‭,‬‭ ‭, and‬
‭iscount_percentage‬
d ‭. Implement functions to apply‬‭a discount to a‬
‭product and calculate the final price.‬
‭9.‬ ‭Struct with Pointer Members‬
‭Define a struct‬‭ Person‬‭that contains a pointer to‬‭a dynamically allocated‬
‭string for the person's name. Write a program to initialize and free the‬
‭memory used by the struct.‬
‭10.‬ ‭Linked List Implementation Using Structs‬
‭Create a linked list using a struct‬‭ Node‬‭that contains‬‭an integer data field‬
‭and a pointer to the next node. Implement functions to insert, delete, and‬
‭display nodes in the list.‬
‭Union and Pointer Programs‬

‭1.‬ ‭Define a Simple Union for a Number‬


‭Create a union‬‭ Number‬‭with an integer and a float.‬‭Initialize it with values‬
‭and print both fields to observe how data is stored in a union.‬
‭2.‬ ‭Union for Storing a Character or an Integer‬
‭Write a union‬‭ CharOrInt‬‭that can store either a‬‭ char‬‭or an‬‭ int‬ ‭. Initialize‬
‭and display values for both types, demonstrating how the memory overlap‬
‭works.‬
‭3.‬ ‭Union for Storing Multiple Data Types‬
‭Define a union‬‭ Data‬‭that can hold an‬‭ int‬ float‬
‭, a‬‭ char‬
‭,‬‭or a‬‭ ‭. Write a‬
‭program that assigns and prints different types of values one at a time,‬
‭showing that only one field holds a valid value at a time.‬
‭4.‬ ‭Union for Byte-Level Manipulation‬
‭Create a union‬‭ ByteManipulator‬‭with an integer and‬‭a character array‬
‭of size 4. Write a program to assign an integer to the union and print its‬
‭individual bytes.‬
‭5.‬ ‭Union with Input from the User‬
‭Write a program where the user chooses whether to enter an integer or a‬
‭float, and store the input in a union. Display the entered value accordingly.‬
‭6.‬ ‭Simple Union for Storing Shapes‬
‭Define a union‬‭ Shape‬‭with fields for the radius of‬‭a circle (float) and the‬
‭side of a square (int). Initialize and print values for both.‬
‭7.‬ ‭Union for Storing Exam Scores‬
‭Write a union‬‭ ExamScore‬‭to store an integer score‬‭or a character grade.‬
‭Create a program that assigns and prints both types of values one after the‬
‭other.‬
‭8.‬ ‭Union for Bitwise Access‬
‭Define a union‬‭ BitAccess‬‭with an integer and a struct‬‭with four 8-bit‬
‭fields (characters). Assign an integer value and display the individual bytes‬
‭of the integer.‬
‭9.‬ ‭Union for Storing Color Information‬
‭Create a union‬‭Color‬‭that can store either an RGB‬‭value (struct with red,‬
‭ reen, blue) or a single hexadecimal color code (unsigned int). Write a‬
g
‭program to store and print both formats.‬
‭10.‬ ‭Union for Handling Employee Type‬
‭Write a union‬‭ Employee‬‭that can store either a worker’s‬‭hourly wage‬
‭(float) or a salaried employee’s annual salary (int). Create a program that‬
‭assigns and displays both fields based on the employee type.‬

‭Slightly More Advanced Union Programs‬


‭1.‬ ‭Union for Different Measurement Systems‬
‭Create a union‬‭ Measurement‬‭that can store distance‬‭either in meters‬
‭(float) or feet (int). Implement functions to convert and display the‬
‭measurement in both units.‬
‭2.‬ ‭Union with Enum for Data Type Selection‬
‭Define a union‬‭ Value‬‭that can store an integer, a‬‭float, or a string‬
‭(character array), along with an enum to keep track of the active type.‬
‭Write a program to demonstrate the use of this union and enum‬
‭combination.‬
‭3.‬ ‭Union for Memory-Efficient Student Data‬
‭Write a program where a union‬‭ StudentInfo‬‭holds either‬‭an integer‬
‭student ID or a floating-point GPA to save memory. Assign and print both‬
‭types of data for multiple students.‬
‭4.‬ ‭Union for Packet Data Interpretation‬
‭Define a union‬‭ Packet‬‭that can represent network packet‬‭data either as‬
‭an integer or a character array. Write a program to simulate reading and‬
‭displaying the raw packet data in both forms.‬
‭5.‬ ‭Union for Overlapping Structs‬
‭Create a union‬‭ MixedData‬‭that includes two different‬‭structs: one for‬
‭storing a 2D point and another for storing a 3D point. Write a program to‬
‭demonstrate how overlapping data works when switching between the two‬
‭structs.‬
‭6.‬ ‭Union for Currency Conversion‬
Currency‬‭that stores a monetary value‬‭either as‬‭
‭Define a union‬‭ int‬
float‬‭(fractional). Implement functions‬‭to convert‬
(‭ whole dollars) or‬‭
‭between different currencies, storing the result in the union.‬
‭7.‬ ‭Union for Storing Sensor Readings‬
‭Write a union‬‭ SensorData‬‭to store sensor readings‬‭in different units‬
‭(temperature in Celsius as float, humidity as integer). Implement a program‬
‭that simulates receiving sensor data and prints the readings in their‬
‭respective units.‬
‭8.‬ ‭Union for Efficient Memory Use in a Banking System‬
BankTransaction‬‭that stores either‬‭a‬‭
‭Create a union‬‭ deposit‬‭(int) or a‬
‭ithdrawal‬‭(float). Write a program to simulate a‬‭transaction system‬
w
‭where memory is efficiently managed using this union.‬
‭9.‬ ‭Union with Array Access‬
‭Write a program using a union‬‭ ArrayUnion‬‭that has‬‭a field for an integer‬
‭and another field as an array of 4 bytes. Assign an integer and print both‬
‭the integer and individual bytes using the array.‬
‭10.‬ ‭Union for Embedded System Data Representation‬
‭In an embedded system, data from sensors might need to be represented‬
‭in different forms. Create a union‬‭EmbeddedData‬‭to‬‭store either 32-bit‬
‭integer data or four 8-bit sensor readings. Write a program to simulate‬
‭storing and reading data in both forms.‬

‭Pointer Based Programs‬


‭11.‬ ‭Pointer to an Integer‬
‭ rite a program that demonstrates basic pointer usage by declaring an‬
W
‭integer, initializing it, and printing its value and address using a pointer.‬
‭12.‬‭Pointer Arithmetic with an Array‬
‭Create a program where an array of integers is accessed using pointer‬
‭arithmetic. Print the elements and their addresses using pointers.‬
‭13.‬‭Pointer to a Struct‬
‭Define a‬‭ Student‬‭struct and create a pointer to a‬‭ Student‬‭variable.‬
‭Initialize the struct using the pointer and print the values of its members.‬
‭14.‬‭Pointer to a Union‬
‭Create a union‬‭ Data‬‭that can store an‬‭
int‬‭or a‬‭float‬‭.‬‭Use a pointer to‬
int‬‭and‬‭
t‭he union to assign and print the values for both‬‭ float‬‭members.‬
‭15.‬‭Pointer to Pointer (Double Pointer)‬
‭Write a program that demonstrates a pointer to a pointer, where you use a‬
‭ ouble pointer to store the address of a single pointer. Print the value,‬
d
‭pointer address, and double pointer address.‬
‭16.‬‭Pointer to an Array‬
‭Define an array of integers and a pointer to the array. Use the pointer to‬
‭iterate through and print the elements of the array.‬
‭17.‬‭Dynamic Memory Allocation for an Array‬
‭Use‬‭ malloc‬‭to dynamically allocate memory for an array‬‭of integers.‬
‭Initialize the array elements using pointers and print them. Free the‬
‭memory after use.‬
‭18.‬‭Passing Pointers to Functions‬
‭Create a function that takes an integer pointer as an argument, modifies‬
‭the value, and prints the result. Demonstrate this by passing the address of‬
‭an integer to the function.‬
‭19.‬‭Pointer to a Function‬
‭Write a program that demonstrates how to store a function’s address in a‬
‭pointer and call the function using the pointer. Use a simple function like‬
‭one that adds two numbers.‬
‭20.‬‭Swap Two Numbers Using Pointers‬
‭Create a‬‭swap‬‭function that takes two integer pointers‬‭as arguments and‬
‭swaps the values of the two integers. Call this function from the main‬
‭program.‬

‭Advanced Pointer-Based Programs‬


‭1.‬ ‭Pointer to an Array of Structs‬
‭Define a‬‭ Book‬‭struct, create an array of‬‭
Book‬‭structs,‬‭and use a pointer to‬
‭the array to initialize and print the details of each book.‬
‭2.‬ ‭Dynamic Array of Structs‬
‭Use‬‭ malloc‬‭to dynamically allocate memory for an array‬‭of structs.‬
‭Populate the array with data, print the data, and then free the allocated‬
‭memory.‬
‭3.‬ ‭Pointer to Union Array‬
‭Create a union‬‭ PersonData‬‭that can store either an‬‭ID (int) or a name‬
‭(char array). Use a pointer to an array of unions to store data for multiple‬
‭people and print their details.‬
‭4.‬ ‭Dynamic Memory Allocation for Structs‬
‭Write a program that dynamically allocates memory for a‬‭ Student‬‭struct‬
‭ sing‬‭
u malloc‬ ‭. Initialize the struct using pointers and print its data. Free‬
‭the memory after use.‬
‭5.‬ ‭Pointer to a Function for Sorting‬
‭Implement a sorting algorithm (like bubble sort) and use a pointer to a‬
‭comparison function (‬‭ greater‬‭or‬‭ less‬‭) to sort the‬‭array in either‬
‭ascending or descending order.‬
‭6.‬ ‭Pointer to Pointer with Arrays (2D Array)‬
‭Use a pointer-to-pointer to represent a dynamically allocated 2D array of‬
‭integers. Allocate memory for the array, fill it with values, print it, and then‬
‭free the memory.‬
‭7.‬ ‭Pointer to Functions Array‬
‭Create an array of function pointers, where each function performs a basic‬
‭mathematical operation (add, subtract, multiply, divide). Use the function‬
‭pointer array to call these functions dynamically.‬
‭8.‬ ‭Callback Functions Using Function Pointers‬
‭Implement a callback mechanism where a function is passed as an‬
‭argument to another function. The callback function can perform‬
‭operations like printing, summing, etc., on an array of integers.‬
‭9.‬ ‭Pointer-Based String Manipulation‬
‭Use a pointer to manipulate and reverse a string without using array‬
‭indexing. Demonstrate operations like copying, concatenating, and‬
‭reversing strings using only pointers.‬
‭10.‬ ‭Dynamic Memory Allocation for Union Arrays‬
‭Write a program that dynamically allocates memory for an array of unions,‬
‭where the union can hold either an integer or a float. Use pointers to‬
‭initialize and print the values.‬
‭11.‬‭Pointer to an Array of Pointers (String Array)‬
‭Define an array of strings using pointers and a pointer to that array. Access‬
‭and print each string using pointer arithmetic.‬
‭12.‬ ‭Function Returning a Pointer‬
‭Create a function that returns a pointer to the largest element in an array.‬
‭Use this function to find and print the largest element in a dynamically‬
‭allocated array.‬
‭13.‬ ‭Dynamic Array of Pointers to Structs‬
‭Write a program that dynamically allocates memory for an array of pointers‬
Employee‬‭structs. Initialize each struct and print‬‭the details, then free‬
‭to‬‭
‭the memory.‬
‭14.‬ ‭Pointer to a Constant vs Constant Pointer‬
‭Create a program to demonstrate the difference between a "pointer to‬
‭constant" and a "constant pointer." Show how each is used and how they‬
‭differ in mutability.‬
‭15.‬ ‭Multi-Level Pointers (Pointer to Pointer to Pointer)‬
‭Implement a multi-level pointer example where a pointer to a pointer to a‬
‭pointer is used. Print the values at different levels of indirection.‬
‭16.‬ ‭Pointer to a Struct with Dynamic Memory Allocation‬
Person‬‭with dynamically allocated‬‭fields (like‬‭
‭Define a struct‬‭ char*‬
‭ame‬
n ‭). Use pointers to allocate memory for the name‬‭field and free it after‬
‭use.‬
‭17.‬ ‭Dynamic Linked List Using Structs and Pointers‬
‭Create a singly linked list using pointers and structs. Implement functions‬
‭to add, remove, and traverse the list. Use dynamic memory allocation to‬
‭add new nodes.‬
‭18.‬ ‭Function Pointer as a Parameter in Struct‬
‭Define a struct‬‭ Operation‬‭with a field for a function‬‭pointer. Create‬
‭functions for addition, subtraction, etc., and pass them to the struct’s‬
‭function pointer to perform operations dynamically.‬
‭19.‬ ‭Circular Linked List Using Pointers‬
‭Implement a circular linked list using pointers and structs. Write functions‬
‭to insert, delete, and display the list, ensuring the circular property is‬
‭maintained.‬
‭20.‬ ‭Pointer to a Struct with a Union‬
‭Create a struct that contains a union as one of its members. Use pointers‬
‭to dynamically allocate memory for this struct, initialize both struct and‬
‭union fields, and print the values.‬
‭Sorting-based programs‬

‭1.‬ ‭Bubble Sort‬

‭ oal: Implement the Bubble Sort algorithm to sort an array of integers in‬
G
‭ascending order.‬

‭ escription: In each pass, adjacent elements are compared, and if they are‬
D
‭in the wrong order, they are swapped. The process repeats until the entire‬
‭array is sorted.‬

‭Input: Unsorted array of integers‬

‭Output: Sorted array in ascending order‬

‭2.‬ ‭Selection Sort‬

‭ oal: Implement the Selection Sort algorithm to sort an array of integers in‬
G
‭descending order.‬

‭ escription: This algorithm repeatedly selects the smallest/largest element‬


D
‭from the unsorted portion of the array and swaps it with the first unsorted‬
‭element, progressively shrinking the unsorted portion.‬

‭Input: Unsorted array of integers‬

‭Output: Sorted array in descending order‬

‭3.‬ ‭Insertion Sort‬

‭ oal: Implement the Insertion Sort algorithm to sort an array of‬


G
‭floating-point numbers in ascending order.‬

‭ escription: Insertion Sort works by building a sorted section of the array‬


D
‭one element at a time, inserting each new element into its correct position‬
‭relative to the already sorted elements.‬

‭Input: Unsorted array of floating-point numbers‬


‭Output: Sorted array in ascending order‬

‭4.‬ ‭Quick Sort‬

‭ oal: Implement the Quick Sort algorithm to sort an array of integers using‬
G
‭a recursive approach.‬

‭ escription: Quick Sort is a divide-and-conquer algorithm. It picks a "pivot"‬


D
‭element, partitions the array into two halves such that elements smaller‬
‭than the pivot are on one side, and larger elements are on the other. It then‬
‭recursively sorts the subarrays.‬

‭Input: Unsorted array of integers‬

‭Output: Sorted array in ascending order‬

‭5.‬ ‭Merge Sort‬

‭ oal: Implement the Merge Sort algorithm to sort an array of integers using‬
G
‭recursion.‬

‭ escription: Merge Sort is also a divide-and-conquer algorithm. It‬


D
‭recursively divides the array into two halves, sorts each half, and then‬
‭merges the two sorted halves into a single sorted array.‬

‭Input: Unsorted array of integers‬

‭Output: Sorted array in ascending order‬


‭Dynamic Memory Allocation‬

‭Basic Programs:‬
‭ . Dynamic memory allocation for an integer:‬
1
‭Allocate memory for an integer using malloc and free it after storing and‬
‭printing a value.‬

‭ . Dynamic memory allocation for an array of integers:‬


2
‭Allocate memory for an array of integers using malloc, input values, and‬
‭print them.‬

‭ . Dynamic memory allocation using calloc for an array of floats:‬


3
‭Allocate memory using calloc, which initializes the allocated memory to‬
‭zero.‬

‭ . Reallocation using realloc for resizing an array:‬


4
‭Create an integer array, then use realloc to increase or decrease its size‬
‭dynamically.‬

‭ . Freeing dynamically allocated memory:‬


5
‭Write a program that allocates memory for a string and ensures the‬
‭memory is freed properly after use.‬

‭Slightly Advanced Programs:‬


‭ . Dynamic 2D array allocation:‬
1
‭Allocate memory for a 2D array using a pointer to pointers, then input and‬
‭display values in a matrix form.‬

‭ . Dynamic memory allocation for an array of structures:‬


2
‭Allocate memory for an array of structures (e.g., for storing details of‬
‭multiple students) and print the stored data.‬
‭ . Dynamic string concatenation:‬
3
‭Dynamically allocate memory for two strings, concatenate them using‬
‭realloc, and print the result.‬

‭ . Creating a dynamic linked list:‬


4
‭Create a singly linked list where each node is dynamically allocated.‬
‭Implement insertion and deletion of nodes.‬

‭ . Dynamic memory for a binary tree:‬


5
‭Write a program that dynamically allocates memory for binary tree nodes‬
‭and performs basic tree operations (insertion, traversal).‬

‭ . Dynamic matrix multiplication:‬


6
‭Allocate memory dynamically for two matrices, multiply them, and display‬
‭the resulting matrix.‬

‭ . Dynamic memory management for graph (adjacency matrix):‬


7
‭Dynamically allocate memory for the adjacency matrix of a graph and‬
‭implement basic operations like adding and removing edges.‬

‭ . Dynamic memory handling for a stack (array implementation):‬


8
‭Implement a stack using dynamic memory allocation where the array‬
‭grows or shrinks depending on the number of elements.‬

‭ . Dynamic circular queue:‬‭Implement a circular queue‬‭using dynamic‬


9
‭memory, adjusting the size dynamically as elements are added or‬
‭removed.‬

‭ 0. Dynamic memory allocation for sparse matrix representation:‬


1
‭Dynamically allocate memory to store a sparse matrix using arrays to store‬
‭only non-zero elements, along with their positions.‬
‭Recursion Based Programs‬

‭Basic Programs:‬
‭ . Factorial of a number:‬‭Calculate the factorial‬‭of a given number using‬
1
‭recursion.‬

‭ . Fibonacci series:‬‭Generate the Fibonacci sequence‬‭up to a given‬


2
‭number using recursion.‬

‭3. Sum of digits:‬‭Find the sum of digits of a number‬‭using recursion.‬

‭4. Reverse a string:‬‭Write a program to reverse a‬‭string using recursion.‬

‭ . Power of a number:‬‭Calculate (a raised to the power‬‭of b) using‬


5
‭recursion.‬

‭ . Greatest common divisor (GCD):‬‭Find the GCD of‬‭two numbers using‬


6
‭the Euclidean algorithm and recursion.‬

‭ . Binary search:‬‭Implement binary search using recursion‬‭on a sorted‬


7
‭array.‬

‭ . Sum of first N natural numbers:‬‭Write a recursive‬‭function to calculate‬


8
‭the sum of the first N natural numbers.‬

‭ . Check if a string is palindrome:‬‭Use recursion‬‭to check whether a‬


9
‭given string is a palindrome.‬

‭10. Harmonic sum:‬‭Compute the harmonic sum using recursion.‬

‭Intermediate Programs:‬
‭11. Towers of Hanoi:‬‭Solve the Towers of Hanoi problem‬‭using recursion.‬

‭ 2. Permutations of a string:‬‭Generate all permutations‬‭of a given string‬


1
‭using recursion.‬
‭ 3. N-th Tribonacci number:‬‭Find the N-th Tribonacci number‬
1
‭(generalization of Fibonacci with 3 terms) using recursion.‬

‭ 4. Recursive function for sum of squares:‬‭Calculate‬‭the sum of‬


1
‭squares of the first N numbers using recursion.‬

‭ 5. Check if a number is prime:‬‭Check if a given number‬‭is prime using‬


1
‭recursion.‬

‭ 6. Decimal to binary conversion:‬‭Convert a decimal‬‭number to its‬


1
‭binary representation using recursion.‬

‭ 7. Count the number of digits in a number:‬‭Use recursion‬‭to count the‬


1
‭number of digits in a number.‬

‭ 8. Josephus problem:‬‭Solve the Josephus problem using‬‭recursion,‬


1
‭where people stand in a circle and every Kth person is eliminated.‬

‭ 9. Find the maximum element in an array:‬‭Use recursion‬‭to find the‬


1
‭maximum element in an array.‬

‭ 0. Recursive merge sort:‬‭Implement the merge sort‬‭algorithm using‬


2
‭recursion to sort an array.‬

‭Enum Based Programs‬

‭Basic Programs:‬
‭ . Basic enum declaration and usage:‬‭Define an enum‬‭for days of the‬
1
‭week and print a specific day using the enum.‬

‭ . Enum with a switch case:‬ ‭Create an enum for traffic‬‭light signals‬


2
‭(Red, Yellow, Green) and use a switch case to print the meaning of each‬
‭signal.‬
‭ . Enum for error codes:‬‭Define an enum for various error codes (e.g.,‬
3
‭SUCCESS, ERROR_FILE_NOT_FOUND) and handle them using a‬
‭function.‬

‭ . Enum with custom values:‬‭Create an enum where the‬‭values start‬


4
‭from a specific number (e.g., MONDAY = 1, TUESDAY = 2, etc.) and print‬
‭their values.‬

‭ . Enum for months of the year:‬‭Define an enum for‬‭the 12 months of the‬


5
‭year and write a program that takes an integer input and returns the‬
‭corresponding month name.‬

‭Intermediate Programs:‬
‭ . Enum for compass directions:‬‭Create an enum for‬‭the four compass‬
6
‭directions (North, East, South, West) and use it in a program that controls‬
‭the movement of an object in a 2D plane.‬

‭ . Enum with bitwise operations:‬‭Define an enum for‬‭file permissions‬


7
‭(READ = 1, WRITE = 2, EXECUTE = 4), then use bitwise operations to set‬
‭and check multiple permissions at once.‬

‭ . Enum for handling menu options:‬‭Use an enum to‬‭define menu‬


8
‭options for a program (e.g., ADD, DELETE, VIEW, EXIT), then implement‬
‭a basic command-line interface using this enum.‬

‭ ‭.‬ Enum for card suits in a card game:‬‭Create an enum‬‭for the four suits‬
9
‭in a deck of cards (Hearts, Diamonds, Clubs, Spades) and write a program‬
‭that uses this enum to simulate drawing cards.‬

‭ 0. Enum for HTTP response codes:‬‭Define an enum for‬‭common HTTP‬


1
‭status codes (e.g., OK = 200, NOT_FOUND = 404,‬
‭INTERNAL_SERVER_ERROR = 500) and use it to handle responses in a‬
‭simple web server simulation.‬
‭Modules Based Programs‬

‭Programs for stdio.h (Standard Input/Output)‬


‭ . Basic I/O Program:‬‭Write a program that takes an‬‭integer, a float, and a‬
1
‭string input from the user and prints them in a formatted way using scanf()‬
‭and printf().‬

‭ . Character Input/Output:‬‭Create a program that reads‬‭multiple‬


2
‭characters using getchar() and prints them using putchar().‬

‭ . File Handling Basics:‬‭Write a program to open a‬‭file, write some text‬


3
‭into it using fprintf(), and read it back using fscanf().‬

‭ . Reading from a file:‬‭Write a program that reads‬‭content from a text file‬


4
‭character by character using fgetc() and counts the number of words and‬
‭lines.‬

‭ . Formatted File Writing:‬‭Create a program that takes‬‭a list of student‬


5
‭names and grades and writes them to a file in a formatted manner using‬
‭fprintf().‬

‭Programs for stdlib.h (Standard Library)‬


‭ . Dynamic Memory Allocation (Array):‬‭Write a program‬‭that‬
6
‭dynamically allocates memory for an integer array using malloc(), takes‬
‭input from the user, and then prints the array.‬

‭ . Dynamic 2D Array:‬‭Use calloc() to allocate memory‬‭for a 2D array, take‬


7
‭input, and print the matrix.‬
‭ . Reallocation of Memory:‬‭Write a program where you allocate an array‬
8
‭dynamically, then resize it using realloc(), and print both the original and‬
‭resized arrays.‬

‭ . Random Number Generator:‬‭Create a program that‬‭generates random‬


9
‭numbers using rand() and sorts them. Ensure to use srand() to seed the‬
‭generator with the current time.‬

‭ 0. Convert String to Number:‬‭Write a program that‬‭takes numeric‬


1
‭strings from the user and converts them to integers, floats, and long‬
‭integers using atoi(), atof(), and atol().‬

‭Programs for string.h (String Handling)‬


‭ 1. String Length and Copy:‬‭Write a program that takes‬‭a string from the‬
1
‭user, calculates its length using strlen(), and creates a copy of it using‬
‭strcpy().‬

‭ 2. String Concatenation:‬‭Write a program that concatenates‬‭two strings‬


1
‭provided by the user using strcat() and prints the result.‬

‭ 3. String Comparison:‬‭Implement a program that compares‬‭two strings‬


1
‭using strcmp() and informs the user whether they are equal or not.‬

‭ 4. String Tokenization:‬‭Create a program that splits‬‭a string into tokens‬


1
‭based on spaces and commas using strtok() and prints each token.‬

‭ 5. Find Substring:‬‭Write a program that finds if‬‭one string is a substring‬


1
‭of another using strstr() and prints its position.‬

‭Programs for math.h (Mathematics Library)‬


‭ 6. Power Calculation:‬‭Create a program that raises‬‭a number to a power‬
1
‭(e.g., x^y) using the pow() function.‬

‭ 7. Square Root Finder:‬‭Write a program that takes‬‭a positive number as‬


1
‭input and calculates its square root using sqrt().‬
‭ 8. Trigonometric Functions:‬‭Implement a program that calculates and‬
1
‭prints the sine, cosine, and tangent of an angle (in radians) using sin(),‬
‭cos(), and tan().‬

‭ 9. Round to Ceiling/Floor:‬‭Create a program that‬‭rounds a float value to‬


1
‭its nearest integer using ceil() and floor() functions.‬

‭ 0. Absolute Value Calculator:‬‭Write a program that‬‭calculates the‬


2
‭absolute value of an integer using the abs() function.‬

‭Programs for time.h (Time Library)‬


‭ 1. Current Date and Time:‬‭Write a program that prints‬‭the current date‬
2
‭and time in a human-readable format using time() and ctime().‬

‭ 2. Time Difference Calculator:‬‭Write a program that‬‭calculates and‬


2
‭prints the time difference between two time instances using difftime().‬

‭ 3. Clock Function Usage:‬‭Create a program that measures‬‭the‬


2
‭execution time of a simple for-loop using the clock() function.‬

‭ 4. Custom Date Formatting:‬‭Write a program that formats‬‭the current‬


2
‭date and time into a custom format (e.g., dd-mm-yyyy hh:mm:ss) using‬
‭strftime().‬

‭ 5. Timer Using time():‬‭Write a countdown timer using‬‭time(), where the‬


2
‭user specifies the number of seconds to count down.‬

‭Programs for ctype.h (Character Handling)‬


‭ 6. Alphabet Check:‬‭Write a program that checks if‬‭a character entered‬
2
‭by the user is an alphabetic letter using isalpha().‬

‭ 7. Digit Checker:‬‭Implement a program that checks‬‭if a character‬


2
‭entered by the user is a digit using isdigit().‬
‭ 8. Convert to Uppercase/Lowercase:‬‭Create a program that converts a‬
2
‭string to uppercase and lowercase using toupper() and tolower().‬

‭ 9. Whitespace Checker:‬‭Write a program that checks‬‭if a character is a‬


2
‭whitespace using isspace().‬

‭ 0. Alphanumeric Checker:‬‭Write a program that checks‬‭if a character is‬


3
‭either a digit or a letter using isalnum().‬

‭Programs for stdbool.h (Boolean Type Library)‬


‭ 1. Boolean Type Program:‬‭Write a program that demonstrates‬‭the use‬
3
‭of bool, true, and false values in controlling program flow (e.g., a flag to‬
‭stop/continue a loop).‬

‭ 2. Boolean Array Example:‬‭Create a program that uses‬‭a boolean array‬


3
‭to track whether certain numbers (e.g., prime numbers) are true or false.‬

‭ 3. Multiple Condition Checking:‬‭Implement a program‬‭that uses‬


3
‭boolean variables to check multiple conditions in a loop.‬

‭Programs for limits.h (Limits of Data Types)‬


‭ 4. Data Type Limits:‬‭Write a program that prints‬‭the minimum and‬
3
‭maximum values of various data types (e.g., int, char, long) using macros‬
‭from limits.h.‬

‭ 5. Overflow Handling:‬‭Create a program that demonstrates‬‭what‬


3
‭happens when values exceed the limit of a data type (e.g., trying to store a‬
‭number larger than INT_MAX).‬

‭Programs for float.h (Limits of Floating Point Types)‬


‭ 6. Float Precision Check:‬‭Write a program that prints‬‭the minimum and‬
3
‭maximum values for float and double using macros from float.h.‬
‭ 7. Float Range Program:‬‭Implement a program that checks if a given‬
3
‭floating-point number lies within the valid range for float and double types.‬

‭Programs for assert.h (Diagnostics Library)‬


‭ 8. Assertion Example:‬‭Create a program that uses‬‭assert() to check a‬
3
‭precondition (e.g., check that a divisor is non-zero before division).‬

‭ 9. Precondition Checking:‬‭Write a program that takes‬‭two integers and‬


3
‭divides them, using assert() to ensure the second integer is not zero‬

‭Programs for errno.h (Error Handling)‬


‭ 0. Error Code Handling:‬‭Write a program that performs‬‭division and‬
4
‭uses errno to check for division by zero or other math-related errors,‬
‭printing appropriate error messages.‬

‭String Based programs‬

‭1.‬ ‭Longest Palindromic Substring:‬


‭Find the longest palindromic substring in a given string.‬

‭Focus: Dynamic programming, efficient substring searching.‬

‭2.‬ ‭Implement Regular Expression Matching:‬


‭Implement basic regular expression matching for patterns like '.' (any‬
‭character) and '*' (zero or more occurrences).‬

‭Focus: Recursion, backtracking, pattern matching.‬

‭3.‬ ‭Longest Common Subsequence (LCS):‬


‭Find the longest common subsequence between two strings.‬
‭Focus: Dynamic programming, string comparison.‬

‭4.‬ ‭Longest Common Prefix:‬


‭Find the longest common prefix from an array of strings.‬

‭Focus: Efficient string searching and manipulation.‬

‭5.‬ ‭String Compression‬‭:‬


‭Compress a string such that consecutive repeated characters are replaced‬
‭by the character followed by its count (e.g., "aaabbc" becomes "a3b2c1").‬

‭Focus: String traversal, handling consecutive characters.‬

‭6.‬ ‭Implement strtok() Function:‬


‭Implement the functionality of the strtok() function, which tokenizes a string‬
‭based on delimiters.‬

‭Focus: Tokenization, handling memory, and string manipulation.‬

‭7.‬ ‭Minimum Number of Insertions and Deletions to Transform One‬


‭String into Another:‬
‭Given two strings, find the minimum number of insertions and deletions‬
‭required to transform one string into another.‬

‭Focus: Dynamic programming, edit distance calculation.‬

‭8.‬ ‭KMP (Knuth-Morris-Pratt) Algorithm for Pattern Searching:‬


‭Implement the KMP algorithm to efficiently search for a pattern in a string.‬

‭ ocus: String pattern matching, preprocessing pattern strings, and‬


F
‭optimization.‬

‭9.‬ ‭Rabin-Karp Algorithm for String Matching:‬


‭Implement the Rabin-Karp algorithm for searching a pattern in a string‬
‭using hashing.‬

‭Focus: Hashing, rolling hash, and pattern matching.‬


‭10.‬ ‭Boyer-Moore Algorithm for String Matching:‬
‭Implement the Boyer-Moore algorithm to efficiently find a pattern in a string‬
‭by skipping unnecessary comparisons.‬

‭Focus: Pattern matching, bad character rule, and good suffix rule.‬

‭Array based Programs‬

‭ . Reverse an Array:‬‭Write a program to reverse the‬‭elements of an array‬


1
‭without using another array.‬

‭ . Array Rotation:‬‭Rotate the elements of an array‬‭by a given number of‬


2
‭positions in both left and right directions.‬

‭ . Find Maximum and Minimum:‬‭Write a program to find‬‭the maximum‬


3
‭and minimum element in an array.‬

‭ . Merge Two Arrays:‬‭Merge two sorted arrays into‬‭one sorted array‬


4
‭without using any sorting algorithm.‬

‭ . Find Second Largest Element:‬‭Write a program to‬‭find the second‬


5
‭largest element in an array.‬

‭ . Frequency of Elements:‬‭Determine the frequency‬‭of each element in‬


6
‭an array, including how many times it appears.‬

‭ . Check if Array is Sorted:‬‭Write a program to check‬‭whether the‬


7
‭elements of an array are sorted in ascending or descending order.‬

‭8. Find Duplicates:‬‭Identify and print the duplicate‬‭elements in an array.‬

‭ . Sum of Array Elements:‬‭Calculate the sum of all‬‭elements in an array,‬


9
‭as well as the sum of even and odd elements separately.‬

‭ 0. Array Elements in Pairs that Add to a Number:‬‭Find all pairs of‬


1
‭elements in an array whose sum equals a given number.‬
‭C programs featuring 1D, 2D, and 3D arrays.‬

‭1D Arrays‬
‭1.‬ ‭Find Element at a Specific Index:‬‭Write a program‬‭to retrieve the‬
‭element at a specific index in a 1D array.‬

‭2.‬ ‭Insert Element at a Given Position:‬‭Insert a new element‬‭into an array at‬


‭a specified position.‬

‭3.‬ ‭Delete an Element from Array:‬‭Delete an element from‬‭the array at a‬


‭given index and shift the remaining elements.‬

‭4.‬ ‭Array Index Search:‬‭Search for the index of a specific‬‭element in the‬


‭array.‬

‭5.‬ ‭Sort an Array:‬‭Implement a sorting algorithm (Bubble‬‭Sort, Selection Sort,‬


‭etc.) to sort a 1D array in ascending and descending order.‬

‭6.‬ ‭Sum and Average of Array Elements:‬‭Calculate the sum‬‭and average of‬
‭all elements in a 1D array.‬

‭7.‬ ‭Find Largest and Smallest Number in Array:‬‭Write a‬‭program to find‬


‭both the largest and smallest elements in a 1D array.‬
‭8.‬ ‭Count Even and Odd Numbers in Array:‬‭Count how many‬‭even and odd‬
‭numbers are present in a 1D array.‬

‭9.‬ ‭Remove Duplicates from Array:‬‭Remove the duplicate‬‭elements from a‬


‭1D array.‬

‭10.‬ ‭Merge Three Arrays:‬‭Merge three arrays into one sorted‬‭array.‬

‭2D Arrays‬
‭11.‬ ‭Matrix Addition:‬‭Write a program to add two 2D‬‭arrays (matrices).‬

‭12.‬ ‭Matrix Subtraction:‬‭Perform subtraction of two matrices‬‭and store the‬


‭result in a third matrix.‬
‭13.‬ ‭Matrix Multiplication:‬‭Multiply two matrices and store the result in a‬
‭third matrix.‬

‭14.‬ ‭Transpose of a Matrix:‬‭Write a program to find the‬‭transpose of a‬


‭matrix (convert rows to columns).‬

‭15.‬ ‭Matrix Determinant:‬‭Calculate the determinant of a‬‭2x2 or 3x3 matrix.‬

‭16.‬ ‭Check Symmetric Matrix:‬‭Write a program to check whether‬‭a given‬


‭2D matrix is symmetric or not.‬

‭17.‬ ‭Sum of Diagonal Elements in a Matrix:‬‭Find the sum‬‭of both primary‬


‭and secondary diagonal elements in a square matrix.‬

‭18.‬ ‭Upper and Lower Triangle of Matrix:‬‭Print the upper‬‭and lower‬


‭triangle of a square matrix separately.‬

‭19.‬ ‭Sparse Matrix Representation:‬‭Convert a 2D matrix‬‭into its sparse‬


‭matrix form by only storing non-zero elements.‬

‭20.‬ ‭Rotate Matrix by 90 Degrees:‬‭Rotate a 2D matrix by‬‭90 degrees‬


‭clockwise or counterclockwise.‬

‭21.‬ ‭3D Arrays:‬‭Write a program to initialize and print‬‭all elements of a 3D‬


‭array.‬

‭22.‬ ‭Matrix Multiplication for 3D Arrays:‬‭Perform matrix‬‭multiplication for‬


‭3D arrays (use small dimensions for simplicity).‬

‭23.‬ ‭Sum of Elements in 3D Array:‬‭Calculate the sum of‬‭all elements in a‬


‭3D array‬

‭24.‬ ‭Search Element in 3D Array:‬‭Search for a specific‬‭element in a 3D‬


‭array and print its position.‬

‭25.‬ ‭Transpose of 3D Array Slices:‬‭Perform transpose operations‬‭on slices‬


‭of a 3D array along different axes.‬

‭26.‬ ‭Find Maximum and Minimum in a 3D Array:‬‭Find the maximum‬‭and‬


‭minimum elements in a 3D array.‬

‭27.‬ ‭Convert 1D to 3D Array:‬‭Convert a 1D array of size‬‭n³ into a 3D array‬


‭and print its elements.‬
‭28.‬ ‭3D Array Rotation:‬‭Implement a program to rotate the elements of a‬
‭3D array along different axes.‬

‭29.‬ ‭Layer-wise Sum in a 3D Array:‬‭Calculate the sum of‬‭elements layer‬


‭by layer in a 3D array.‬

‭30.‬ ‭Boundary Elements of 3D Array:‬‭Print all the boundary elements‬


‭(elements on the "shell") of a 3D array.‬

‭Random Module Based‬

‭Basic Programs‬

‭1.‬ ‭Random Number Generation‬‭:‬


‭○‬ ‭Write a program that generates and prints a random number‬
‭between 1 and 100.‬
‭2.‬ ‭Random Dice Roll Simulator‬‭:‬
‭○‬ ‭Implement a program that simulates rolling a six-sided dice and‬
‭prints the result.‬
‭3.‬ ‭Random Password Generator‬‭:‬
‭○‬ ‭Create a program that generates a random alphanumeric password‬
‭of a specified length.‬
‭4.‬ ‭Random Array Initialization‬‭:‬
‭○‬ ‭Write a program that initializes an array of a specified size with‬
‭random integers and prints the array.‬

‭Intermediate Programs‬

‭5.‬ ‭Random Number Guessing Game‬‭:‬


‭○‬ ‭Develop a program where the computer randomly selects a number‬
‭between 1 and 100, and the user has to guess it. Provide hints for‬
‭higher or lower guesses.‬
‭6.‬ ‭Shuffle an Array‬‭:‬
‭○‬ ‭Write a program that takes an array of integers and shuffles its‬
‭elements randomly.‬
‭7.‬ ‭Random Selection from a List‬‭:‬
‭○‬ ‭Create a program that takes a list of names from the user and‬
‭randomly selects one name from the list.‬
‭○‬

‭Advanced Programs‬

‭8.‬ ‭Monte Carlo Simulation for Pi‬‭:‬


‭○‬ ‭Implement a Monte Carlo method to estimate the value of π by‬
‭randomly generating points in a square and counting how many fall‬
‭within a quarter circle.‬
‭9.‬ ‭Randomized Quick Sort‬‭:‬
‭○‬ ‭Write a program that implements the quicksort algorithm using a‬
‭random pivot selection to improve performance.‬
‭10.‬ ‭Random Maze Generator‬‭:‬
‭○‬ ‭Create a program that generates a simple maze using random‬
‭pathways, using techniques such as depth-first search or recursive‬
‭backtracking.‬

‭FIle Handling Programs‬

‭Basic Programs‬

‭1.‬ ‭Write to a File‬‭:‬


‭○‬ ‭Create a program that takes user input and writes it to a text file.‬
‭2.‬ ‭Read from a File‬‭:‬
‭○‬ ‭Write a program that reads and displays the contents of a text file.‬
‭3.‬ ‭Copy Contents of One File to Another‬‭:‬
‭○‬ ‭Implement a program that copies the contents of one file to another‬
‭file.‬
‭4.‬ ‭Append to a File‬‭:‬
‭○‬ ‭Create a program that allows the user to append text to an existing‬
‭file.‬
‭5.‬ ‭Count Characters in a File‬‭:‬
‭○‬ ‭Write a program that counts and displays the number of characters‬
‭in a text file.‬

‭Intermediate Programs‬

‭6.‬ ‭Count Words in a File‬‭:‬


‭○‬ ‭Implement a program that counts and displays the number of words‬
‭in a text file.‬
‭7.‬ ‭Find and Replace in a File‬‭:‬
‭○‬ ‭Write a program that finds a specific word in a file and replaces it‬
‭with another word.‬
‭8.‬ ‭Sort Lines in a File‬‭:‬
‭○‬ ‭Create a program that reads lines from a file, sorts them‬
‭alphabetically, and writes the sorted lines to a new file.‬
‭9.‬ ‭File Comparison‬‭:‬
‭○‬ ‭Implement a program that compares two files and displays the‬
‭differences between them.‬
‭10.‬ ‭Extract Specific Lines from a File‬‭:‬
‭○‬ ‭Write a program that extracts and writes specific lines (e.g., odd or‬
‭even numbered lines) from a file to a new file.‬

‭Advanced Programs‬

‭11.‬‭CSV File Reader and Writer‬‭:‬


‭○‬ ‭Create a program that reads data from a CSV file and allows the‬
‭user to add new records to it.‬
‭12.‬ ‭Binary File Write and Read‬‭:‬
‭○‬ ‭Implement a program that writes structured data (like a struct) to a‬
‭binary file and reads it back.‬
‭13.‬ ‭File Encryption and Decryption‬‭:‬
‭○‬ W ‭ rite a program that encrypts a text file by shifting characters and‬
‭provides a way to decrypt it.‬
‭14.‬ ‭Record Management System‬‭:‬
‭○‬ ‭Create a program that allows users to add, delete, and view records‬
‭(like student or employee records) stored in a file.‬
‭15.‬ ‭Merge Two Files‬‭:‬
‭○‬ ‭Implement a program that merges the contents of two text files into a‬
‭new file.‬

‭Expert Programs‬

‭16.‬ ‭ ile Compression‬‭:‬


F
‭○‬ ‭Write a program that compresses a text file by replacing sequences‬
‭of repeated characters with a single character and a count.‬
‭17.‬ ‭Log File Analyzer‬‭:‬
‭○‬ ‭Create a program that analyzes a log file, counts occurrences of‬
‭specific events, and summarizes the results.‬
‭18.‬ ‭Backup System‬‭:‬
‭○‬ ‭Implement a program that creates backups of specified files or‬
‭directories by copying them to a backup folder.‬
‭19.‬ ‭Simple Text Editor‬‭:‬
‭○‬ ‭Write a program that allows users to create, edit, and save text files,‬
‭implementing features like opening, saving, and editing.‬
‭20.‬ ‭File Properties Display‬‭:‬
‭○‬ ‭Create a program that displays various properties of a file (like size,‬
‭creation date, last modified date) using file handling techniques.‬

‭INGREDREIER ICYNADAI‬

You might also like