0% found this document useful (0 votes)
5 views3 pages

11Nov_Monday_lab

Uploaded by

sandyvisha661981
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

11Nov_Monday_lab

Uploaded by

sandyvisha661981
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Monday Lab

Q1 Dothraki is planning an attack to usurp King Robert’s throne. King Robert learns
of this conspiracy from Raven and plans to lock the single door through which
the enemy can enter his kingdom. But to lock the door, he needs a key that is an
anagram of a palindrome. He starts to go through his box of strings, checking to
see if they can be rearranged into a palindrome. You are given a string, write a
function possiblePal(char str[ ]) which takes a string as an input and returns YES if
the string can be rearranged into a palindrome else NO. The string will contain
lowercase characters only. (Using dynamic memory allocation)
Example 1:
Input: aaabbbb
Output: YES
Explanation: The rearranged palindrome for the given string is bbaaabb
Example 2:
Input:
cdcdcdcdeeeef
Output:
YES
Explanation: The rearranged palindrome for the given string is ccddeefeeddcc

Q2. Write a program that takes n students (name and


roll number) as input using structures and then sorts the student list based on
their roll numbers and display that.
Test Data :
Input the string :
Enter number of student record to insert: 4
Enter name for student 1: ram
Enter roll number for student 1: 12
Enter name for student 2: shayam
Enter roll number for student 2: 5
Enter name for student 3: love
Enter roll number for student 3: 78
Enter name for student 4: kush
Enter roll number for student 4: 2
Expected Output :
Sorted list of students based on roll number :
Name: kush, Roll Number: 2
Name: shayam, Roll Number: 5
Name: ram, Roll Number: 12
Name: love, Roll Number: 78
Q3 Define a Vehicle structure with fields license_number, model, year, and owner. Inside
owner, create a union to store either individual_name (if owned by a person) or
company_name (if owned by a company). Write a function to input and display vehicle
information, including the appropriate owner type.
Example
Displaying All Vehicles:

Vehicle Information:
License Number: ABC123
Model: Toyota Camry
Year: 2020
Owner (Individual): John Doe
----------------------------------

Q4 Given an array arr[] containing N distances of inch-feet system, such that each
element of the array represents a distance in the form of {inch, feet}. The task is to add all
the N inch-feet distances using structures.
Example

Input: arr[] = { { 10, 3.7 }, { 10, 5.5 }, { 6, 8.0 } };


Output: Feet Sum: 27 Inch Sum: 5.20

Input: arr[] = { { 1, 1.7 }, { 1, 1.5 }, { 6, 8 } };


Output: Feet Sum: 8 Inch Sum: 11.20

Q5.Write a program to implement a student database using structures and perform


operations like add, delete, search and display all student.
Example
Student Database Menu:
1. Add Student
2. Delete Student
3. Search Student
4. Display All Students
5. Exit
Enter your choice: 1

Enter roll number: 101


Enter name: Alice
Enter marks: 89.5
Student added successfully!
Student Database Menu:
1. Add Student
2. Delete Student
3. Search Student
4. Display All Students
5. Exit
Enter your choice: 4

Student Database:
Roll No Name Marks
-------------------------------------------------------------
101 Alice 89.50

Student Database Menu:


1. Add Student
2. Delete Student
3. Search Student
4. Display All Students
5. Exit
Enter your choice: 5
Exiting...

You might also like