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

Module 4

The document contains a series of programming tasks primarily focused on C language, involving structures, unions, and various algorithms. It includes tasks such as managing car and book information, implementing mathematical functions, and creating data management systems for students and patients. Each task outlines specific requirements for struct definitions, function implementations, and expected outputs.

Uploaded by

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

Module 4

The document contains a series of programming tasks primarily focused on C language, involving structures, unions, and various algorithms. It includes tasks such as managing car and book information, implementing mathematical functions, and creating data management systems for students and patients. Each task outlines specific requirements for struct definitions, function implementations, and expected outputs.

Uploaded by

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

SR NO Question 1 Question 2 (Optional)

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.

12 Write a program using a function to calculate the hypotenuse of a right-angled triangle.


SR NO Question 1 Question 2 (Optional)
Write a program in C to separate odd and even integers into separate arrays using
Function.
Test Data :
Input the number of elements to be stored in the array :5
Input 5 elements in the array :
element - 0 : 25
element - 1 : 47 Design a structure named "Car" to store details like car ID, model, and rental rate
13 element - 2 : 42 per day. Write a C program to input data for three cars, calculate the total rental
element - 3 : 56 cost for a specified number of days, and display the results.
element - 4 : 32
Expected Output :
The Even elements are :
42 56 32
The Odd elements are :
25 47
Write a program in C to find the sum of the series 1!/1+2!/2+3!/3+4!/4+5!/5 using the
14
function.
Design and implement a C program to manage student information using structures."

Requirements:

Define a structure named Student to represent a student. The structure should include the
15 following members:

roll_no: An integer to store the student's roll number.


name: A character array to store the student's name.
marks: An array of integers to store the marks obtained in five subjects (e.g., Math, Science,
English, History, Geography).
There is a structure called employee that holds information like employee code, name and
date of joining. Write a program to create an array of structures and enter some data into it.
16
Then ask the user to enter current date. Display the names of those employees whose
tenure is greater than equal to 3 years.
Write a C program for storing information of a student like (student ID, students
17 Write a C program to find a factorial of a number using user-defined function
name, students mark) using structure
Design a program to store and display a Date using a structure with fields for day, month,
Write a program to define a structure Product with fields product_id,
and year. In the same program, use a union to store either a timestamp (as an integer) or a
product_name, and price. Create an array of 5 Product structures, accept data
18 formatted_date (as a string). Provide functions to input and display both formats of the
for each product, and write a function to calculate and display the total price of
date.
all products.

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:

Book Title (string).


Book ID (integer).
26
Book Details (using a union to handle two types of books):
Regular Book (with price and number of pages).
E-Book (with file size and format).
The program should allow the user to select a book type and input its details. Then, display
the details based on the selected book type.
Write a C program to find the LCM (Least Common Multiple) of two numbers using a Write a C program to find the GCD (Greatest Common Divisor) of two numbers
27
user-defined function. using a recursive function.
Write a C program that takes the temperature in Celsius from the user and converts it to
28 Fahrenheit using the formula: F=(9/5)*C+32 Return the Fahrenheit temperature from a
function and display it

You might also like