Best 30 C programming questions on Structures
Q 1. Define a structure to store a student's name and marks, and display the student's details.
Expected Output:
Student Name: John
Marks: 85
Q 2. Define a structure to store employee details (ID, name, and salary), input these details, and display them.
Expected Output:
Employee ID: 101
Employee Name: Alice
Salary: 50000
Q 3. Define a structure to store a point in 2D space (x and y coordinates). Create two points and display their coordinates.
Expected Output:
Point 1: (2, 3)
Point 2: (4, 6)
Q 4. Define a structure to store a date (day, month, year) and input a date from the user, then display it.
Expected Output:
Date: 23/09/2024
Q 5. Define a structure to store a rectangle's length and breadth. Calculate and display its area and perimeter.
Expected Output:
Area = 50
Perimeter = 30
Q 6. Define a structure to store a car's details (model, price). Input two cars and display their details.
Expected Output:
Car 1: Model = Sedan, Price = 20000
Car 2: Model = SUV, Price = 30000
Q 7. Define a structure to store a book's title, author, and price. Create an array of 3 books and display their details.
Expected Output:
Book 1: Title = "C Programming", Author = "Dennis Ritchie", Price = 500
Book 2: Title = "Data Structures", Author = "Mark Allen", Price = 600
Book 3: Title = "Algorithms", Author = "Thomas Cormen", Price = 700
Q 8. Define a structure to store complex numbers and create a function to add two complex numbers.
Expected Output:
Sum = 3 + 7i
Q 9. Define a structure to store a person's name and age. Create a function that checks if a person is eligible to vote (age >= 18).
Expected Output:
Alice is eligible to vote
Q 10. Define a structure to store time in hours, minutes, and seconds. Create a function that adds two times.
Expected Output:
Time sum = 4:45:30
Q 11. Define a structure to store a person's first name, last name, and age. Concatenate the first and last names to display the full name.
Expected Output:
Full Name: John Doe
Age: 25
Q 12. Define a structure to store a student's marks in 3 subjects. Calculate and display the total and average marks.
Expected Output:
Total Marks: 270
Average Marks: 90
Q 13. Define a structure to store a circle's radius and create a function to calculate the area of the circle.
Expected Output:
Area of Circle: 50.27
Q 14. Define a structure to store a box's dimensions (length, width, height) and create a function to calculate its volume.
Expected Output:
Volume of Box: 120
Q 15. Define a structure to store a fraction (numerator and denominator). Create a function to add two fractions and display the result in simplified form.
Expected Output:
Sum = 7/6
Q 16. Define a structure to store a book's title, author, and price. Write a function to compare the prices of two books and display the cheaper one.
Expected Output:
Cheaper book: Data Structures, Price = 600
Q 17. Define a structure to store an employee's ID, name, and salary. Write a function to display the details of the employee with the highest salary from an array of 3 employees.
Expected Output:
Employee with highest salary: John, ID: 103, Salary: 70000
Q 18. Define a structure to store student details (name, roll number, marks in 3 subjects). Write a function to display the student with the highest total marks.
Expected Output:
Top Student: Alice, Roll No: 1, Total Marks = 270
Q 19. Define a structure to store an RGB color (red, green, blue). Write a function to mix two colors (average their RGB values).
Expected Output:
Mixed Color: (128, 128, 128)
Q 20. Define a structure to store a 3D point (x, y, z coordinates). Write a function to calculate the distance between two points.
Expected Output:
Distance between points: 5.20
Q 21. Define a structure to store a student’s ID, name, and marks in two subjects. Create a function to find and display the student with the highest average marks.
Expected Output:
Top Student: John, ID: 101, Average Marks: 90
Q 22. Define a structure to store the dimensions of a cuboid (length, width, height). Write a function to calculate and display its surface area.
Expected Output:
Surface Area of Cuboid: 130
Q 23. Define a structure to store a person’s contact details (name, phone number, email). Write a function to display these details.
Expected Output:
Name: Alice
Phone: 123-456-7890
Email: alice@example.com
Q 24. Define a structure to store a bank account’s details (account number, account holder name, balance). Write a function to deposit an amount into the account.
Expected Output:
New Balance: 1200
Q 25. Define a structure to store the coordinates of a vertex of a triangle (x, y). Write a function to calculate and display the area of the triangle using Heron's formula.
Expected Output:
Area of Triangle: 6.00
Q 26. Define a structure to store a person’s date of birth (day, month, year). Write a function to calculate and display the age of the person.
Expected Output:
Age: 25
Q 27. Define a structure to store an employee's information (ID, name, department, salary). Write a function to update the salary of an employee.
Expected Output:
Updated Salary: 55000
Q 28. Define a structure to store a rectangle's width and height. Write a function to check if it is a square.
Expected Output:
The rectangle is not a square
Q 29. Define a structure to store a person's details (name, age, gender). Write a function to check if the person is a senior citizen (age >= 65).
Expected Output:
John is a senior citizen
Q 30. Define a structure to store an athlete's name, age, and sport. Write a function to display the athlete's details and check if they are eligible for a competition (age <= 30).
Expected Output:
Name: Sarah
Age: 28
Sport: Swimming
Sarah is eligible for the competition
Bikki Singh
Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!