Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1: USING C++ Write a complete C++ program with the following features. Declare a structure Point with two integer members x and y. Define

Exercise 1: USING C++

Write a complete C++ program with the following features.

Declare a structure Point with two integer members x and y. Define a function getInput(),which accepts a Point by reference. Get user input for a Point in this function. Define a function addPoints(), which accepts two Points p1 and p2. The function adds their respective members, and returns a Point which is the sum of two. For example if one point is (2,3), the other is (4,5), the function should return a Point (6,8). In the main(), declare two variables of type Point. Call the function getInput() twice to get the values of these Points from user. Add the two Points using the function addPoints() and display the x and y values of the result returned by the function. EXERCISE 2 using C++ i. Declare a structure Rectangle with two Points as its members, the top left and the bottom right. ii. Declare a variable of type Rectangle and get user input for the two points. iii. Define a function computeArea() which accepts a Rectangle and returns its area. iv. Display the area of the Rectangle in the main(). EXERCISE 3 using c++ i. Declare a structure Time with fields hours and minutes. ii. Declare another structure Flight with fields to store flight ID, arrival time and departure time. iii. Define a function input(Flight *) which allows users enter data for a flight. iv. Define another function display(Flight *) which displays the data for a flight. v. In the main, declare a variable of type Flight and call the input() and display() functions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

Sopve it for me please and select which option is correct

Answered: 1 week ago