Practice 50 C# Structure Programming Questions
Q1. Write a C# program to define a structure to represent a point in a 2D space with x and y coordinates. Create an instance and display the values of x and y.
Input: x = 5, y = 10
Output: x: 5, y: 10
Q2. Write a C# program to define a structure for storing details of a book (title, author, and price). Create an instance and display the book details.
Input: title = "C# Programming", author = "John Doe", price = 19.99
Output: Title: C# Programming, Author: John Doe, Price: 19.99
Q3. Write a C# program to define a structure Student with name, age, and grade as fields. Initialize the structure and print the student's details.
Input: name = "Alice", age = 20, grade = "A"
Output: Name: Alice, Age: 20, Grade: A
Q4. Write a C# program to define a structure for a rectangle and calculate its area and perimeter.
Input: length = 10, width = 5
Output: Area: 50, Perimeter: 30
Q5. Write a C# program to define a structure Date with day, month, and year. Initialize and display the current date.
Input: day = 3, month = 1, year = 2025
Output: Date: 3/1/2025
Q6. Write a C# program to define a structure Employee with name, id, and salary. Display the employee details.
Input: name = "Bob", id = 101, salary = 50000
Output: Name: Bob, ID: 101, Salary: 50000
Q7. Write a C# program to define a structure Circle with radius. Calculate and display the area and circumference of the circle.
Input: radius = 7
Output: Area: 153.94, Circumference: 43.98
Q8. Write a C# program to define a structure Time with hours, minutes, and seconds. Display the time in the format hh:mm:ss.
Input: hours = 10, minutes = 45, seconds = 30
Output: Time: 10:45:30
Q9. Write a C# program to define a structure Point3D with x, y, and z coordinates. Display the 3D point.
Input: x = 2, y = 3, z = 4
Output: Point: (2, 3, 4)
Q10. Write a C# program to define a structure Person with name and age. Initialize and display the person's details.
Input: name = "John", age = 28
Output: Name: John, Age: 28
Q11. Write a C# program to define a structure ComplexNumber with real and imaginary parts. Display the complex number in the form a + bi.
Input: real = 5, imaginary = 3
Output: 5 + 3i
Q12. Write a C# program to define a structure Book with ISBN, title, and author. Initialize and display the book details.
Input: ISBN = "123456789", title = "Learn C#", author = "Jane Smith"
Output: ISBN: 123456789, Title: Learn C#, Author: Jane Smith
Q13. Write a C# program to define a structure Rectangle with length and width. Create a method in the structure to calculate and display the area.
Input: length = 4, width = 3
Output: Area: 12
Q14. Write a C# program to define a structure Student with name, roll number, and marks. Calculate the average marks and display the details.
Input: name = "Emma", roll number = 102, marks = 85
Output: Name: Emma, Roll Number: 102, Marks: 85, Average Marks: 85
Q15. Write a C# program to define a structure Rectangle with length and width. Implement a method to check if the rectangle is a square.
Input: length = 5, width = 5
Output: It is a square.
Q16. Write a C# program to define a structure Circle with radius. Calculate and display the area and perimeter of the circle using a method.
Input: radius = 8
Output: Area: 201.06, Perimeter: 50.24
Q17. Write a C# program to define a structure Employee with name, id, salary, and department. Display the employee's details.
Input: name = "Sam", id = 201, salary = 55000, department = "HR"
Output: Name: Sam, ID: 201, Salary: 55000, Department: HR
Q18. Write a C# program to define a structure Date with day, month, and year. Create a method to check if the year is a leap year.
Input: day = 29, month = 2, year = 2024
Output: It is a leap year.
Q19. Write a C# program to define a structure Point with x and y. Create a method to calculate the distance between two points.
Input: x1 = 1, y1 = 2, x2 = 4, y2 = 6
Output: Distance: 5
Q20. Write a C# program to define a structure Complex with real and imaginary parts. Implement a method to add two complex numbers.
Input: Complex num1 = 3 + 4i, num2 = 1 + 2i
Output: Sum: 4 + 6i
Q21. Write a C# program to define a structure Book with title, author, and price. Implement a method to increase the price by 10%.
Input: title = "C# Basics", author = "Tom", price = 30
Output: New Price: 33
Q22. Write a C# program to define a structure Student with name, marks, and grade. Implement a method to assign grade based on marks.
Input: marks = 85
Output: Grade: A
Q23. Write a C# program to define a structure Person with name, age, and address. Display the person's details.
Input: name = "Tom", age = 40, address = "123 Street, City"
Output: Name: Tom, Age: 40, Address: 123 Street, City
Q24. Write a C# program to define a structure DateTime with hour, minute, and second. Display the time in hh:mm:ss format.
Input: hour = 12, minute = 30, second = 45
Output: Time: 12:30:45
Q25. Write a C# program to define a structure Student with name, age, marks. Create a method to display the student details.
Input: name = "John", age = 22, marks = 75
Output: Name: John, Age: 22, Marks: 75
Q26. Write a C# program to define a structure Account with account number, balance, and account type. Display the account details.
Input: account number = 12345, balance = 5000, account type = "Saving"
Output: Account Number: 12345, Balance: 5000, Account Type: Saving
Q27. Write a C# program to define a structure Circle with radius. Create a method to calculate the diameter of the circle.
Input: radius = 10
Output: Diameter: 20
Q28. Write a C# program to define a structure Rectangle with length and width. Create a method to calculate the perimeter of the rectangle.
Input: length = 4, width = 3
Output: Perimeter: 14
Q29. Write a C# program to define a structure Person with first name, last name, and age. Display the full name and age.
Input: first name = "John", last name = "Doe", age = 30
Output: Full Name: John Doe, Age: 30
Q30. Write a C# program to define a structure Book with title, author, price. Implement a method to display book details.
Input: title = "C# Basics", author = "Tom", price = 19.99
Output: Title: C# Basics, Author: Tom, Price: 19.99
Q31. Write a C# program to define a structure Account with account number, balance. Create a method to deposit money into the account.
Input: account number = 123, balance = 1000, deposit = 500
Output: New Balance: 1500
Q32. Write a C# program to define a structure Triangle with base and height. Create a method to calculate the area of the triangle.
Input: base = 5, height = 10
Output: Area: 25
Q33. Write a C# program to define a structure Movie with title, director, and rating. Display the movie details.
Input: title = "Inception", director = "Christopher Nolan", rating = 8.8
Output: Title: Inception, Director: Christopher Nolan, Rating: 8.8
Q34. Write a C# program to define a structure Person with name and age. Create a method to check if the person is eligible for voting.
Input: name = "Tom", age = 20
Output: Eligible for voting.
Q35. Write a C# program to define a structure Book with title, author, and price. Create a method to apply a discount to the book price.
Input: price = 100, discount = 10%
Output: Discounted Price: 90
Q36. Write a C# program to define a structure Product with name, price, and quantity. Calculate the total value of the product.
Input: price = 50, quantity = 5
Output: Total Value: 250
Q37. Write a C# program to define a structure Student with name, marks, and total marks. Calculate the percentage of the student.
Input: marks = 80, total marks = 100
Output: Percentage: 80%
Q38. Write a C# program to define a structure Person with name and age. Implement a method to check if the person is a senior citizen.
Input: name = "John", age = 65
Output: Senior citizen.
Q39. Write a C# program to define a structure Point with x and y. Implement a method to move the point by given dx and dy values.
Input: x = 2, y = 3, dx = 1, dy = 2
Output: New Position: (3, 5)
Q40. Write a C# program to define a structure Rectangle with length and width. Implement a method to scale the rectangle by a given factor.
Input: length = 4, width = 3, scale factor = 2
Output: New Length: 8, New Width: 6
Q41. Write a C# program to define a structure Account with account number, balance, and account type. Implement a method to check the balance.
Input: account number = 123, balance = 5000
Output: Balance: 5000
Q42. Write a C# program to define a structure Person with first name, last name, and age. Implement a method to display the full name.
Input: first name = "Tom", last name = "Smith"
Output: Full Name: Tom Smith
Q43. Write a C# program to define a structure Book with title, author, and price. Implement a method to check if the price is within a given range.
Input: price = 15, range = 10 to 20
Output: Price is within range.
Q44. Write a C# program to define a structure Movie with title, director, and rating. Create a method to check if the movie has a rating greater than 7.
Input: rating = 8
Output: Rating is greater than 7.
Q45. Write a C# program to define a structure Student with name, roll number, and marks. Calculate the total marks.
Input: marks = 90, 80, 85
Output: Total Marks: 255
Q46. Write a C# program to define a structure Rectangle with length and width. Create a method to calculate the diagonal of the rectangle.
Input: length = 6, width = 8
Output: Diagonal: 10
Q47. Write a C# program to define a structure Product with name, price, and quantity. Create a method to calculate the total price for the product.
Input: price = 20, quantity = 4
Output: Total Price: 80
Q48. Write a C# program to define a structure Student with name, marks, and result. Display the result (Pass/Fail).
Input: marks = 45
Output: Result: Pass
Q49. Write a C# program to define a structure Account with balance. Implement a method to withdraw money from the account.
Input: balance = 5000, withdrawal = 1000
Output: New Balance: 4000
Q50. Write a C# program to define a structure Person with name, age, and address. Create a method to change the address.
Input: name = "John", address = "123 Old St", new address = "456 New St"
Output: Address Updated: 456 New St
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!