Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Structure.

1. Using struct, write a c++ programme to store an employee data:


• Employee number
• First name
• Last name
• Salary
• Bonus
• Net salary = salary + bonus.
2. Create an object of employee with name: emp1 and initialize these data to it:
 Employee number =10
 First name = Ahmad
 Last name= Ali
 Salary= 3000
 Bonus= 500
3. Print the data of emp1.
4. Create another object emp2.
5. Assign the data of emp1 into emp2.
6. Print the first name and last name of emp2.

2. Using struct, write a function that ask the user to enter data of car variables (name, colour ,
maxspeed, model), then output the data.

3. Write a struct (Distance_type) which contain two variables (int feet, float inches),
then declare a function that can sum the feet and inches of two variables . The output should
be like:
 Enter feet and inches of d1 : 33 15
 Enter feet and inches of d2 :14 20
 The sum of feet is: 47
 The sum of inches is: 35

4. Declare a struct student with:


• student_no= 101
• Name= Ali ahmad
• Gpa= 88
• Marks= 50, 80, 90. (as array of size 3).
Then Oputput the data.

5. Declare struct of Book that contain these variable:


• Book number.
• Book Title.
• Book Price.
Then declare an object of Book of size 5, and ask the user to assign data to this object,
then print the results on the screen.
6. Make a structure named Date to store the elements (day, month and year).
Inside the main create two objects from Date structure and ask the user to enter two dates.
You have to check if the dates are equal or not. Display "Dates are equal" otherwise display
"Dates are not equal".

You might also like