Module 4
Module 4
Write a program to store and display information about 5 cars(name, year of launch and
1
price) using an array of structures.
Define a structure named Book with members title (string), author (string), and pages
2
(integer).
Write a program that defines a structure Book with the following members:
Write a recursive function that checks if a string is a palindrome. The function should:
char title[100]
Accept the string as input. char author[100]
3 Compare the first and last characters of the string, then recursively check the substring float price
without the first and last characters. Initialize an array of Book structures with sample data.
Return true if the string is a palindrome, and false otherwise. Write a function to display the details of all books.
Test the function with multiple strings (both palindromes and non-palindromes). Write a function to search for a book by title and return the book's details. If the bo
Demonstrate the program with 3 books.
Write a function to compute the distance between two points
and use it to develop another function that will compute the
area of the triangle whose vertices are A(x1, y1), B(x2, y2),
4
and C(x3, y3). Use these functions to develop a function
which returns a value 1 if the point (x, y) lines inside the
triangle ABC, otherwise a value 0.
Write a program to store and display information about multiple books (title, author, and Write a program to manage a simple ATM system using a union for different
5
price) using an array of structures transaction types like balance inquiry and withdrawal.
6 Write a C Program to Add Two Complex Numbers by Passing Structure to a Function.
Write a program in C to define a structure named Employee with fields for ID, name, and
salary. Accept details of 5 employees from the user and sort them by name in alphabetical
7
order using a function. Display the sorted list.
Define a structure Book with fields title, author, and price. Write functions to:
Add a new book.
Write a C program that defines a function to swap two arrays of the same size without
Display book details.
8 using any extra memory or a third array. The function should swap the elements of both
Calculate the total price of all books.
arrays in place. After calling the function, print the modified arrays.
Implement these functions and demonstrate their usage in a menu-driven
program.
Write a program that replaces two or more consecutive blanks
in a string by a single blank. For example, if the input is
Write a program that converts a string like "124" to an integer
9 Grim return to the planet of apes!!
124.
the output should be
Grim return to the planet of apes!!
10 Write a recursive function to find all prime numbers up to a given number. Create a program to manage bank account details (account number, name, balanc
Write a program in C to define a structure named Employee with fields for id, name, and
salary. Accept details of 5 employees from the user and sort them by salary in ascending
11
order using a function. Display the sorted list.
Requirements:
Define a structure named Student to represent a student. The structure should include the
15 following members:
Define a union Shape containing structures for Circle, Rectangle, and Triangle with relevant
19 parameters.
Write a function to calculate and return the area based on user selection.
Design a structure named "Car" to store details like car ID, model, and rental rate per day.
20 Write a C program to input data for three cars, calculate the total rental cost for a specified
number of days, and display the results.
SR NO Question 1 Question 2 (Optional)
Write a C program that:
Accept number of rows (R) and colums (C) of matrices.
21 Accepts two RxC matrices from the user.
Performs matrix addition.
Displays the resultant matrices after operation.
Create a structure Patient with details: name, age, disease, admission_date, and
Define a structure Complex with fields real and imaginary.
bill_amount.
Write functions to:
Implement functions to:
22 Add two complex numbers.
Accept and display patient records.
Multiply two complex numbers.
List all patients suffering from a specific disease.
Find the magnitude of a complex number.
Calculate and print the total revenue generated by all patients.
23 Write a program in C to compare two strings without using string library functions.
Write a C program to input a 3×3 matrix from the user and compute the sum of its diagonal
elements. Display the entered matrix and the calculated sum.
24
Define a union ExamScore containing fields for three different types of exams: marks_100
(out of 100), grade (A/B/C/D), and percentage.
25
Implement a program that takes student input and selects the appropriate format for
storing scores based on the type of exam.
Write a program for a simple library management system using a structure . The structure
should store: