FRIEND FUNCTION PROGRAM | C++ & PYTHON – SHOUT CODERS

BinarySRCH

CREATE TWO CLASSES dm AND db WHICH STORE THE VALUE OF DISTANCE. WRITE A PROGRAM THAT CAN READ VALUES FOR THE CLASS OBJECTS AND ADD ONE OBJECT OF dm WITH ANOTHER OBJECT OF db.

USE A FRIEND FUNCTION TO CARRY OUT THE ADDITION OPERATION OBJECT THAT STORES THE RESULT MAY BE IN dm OBJECT OR db OBJECT DEPENDING ON THE UNITS ON WHICH THE RESULTS ARE REQUIRED.

THE DISPLAY SHOULD BE IN THE FORMAT OF FEET AND INCHES OR METERS AND CENTIMETERS DEPENDING ON THE OBJECT ON DISPLAY.

C++ PROGRAM:

PYTHON PROGRAM:

Note:

1 foot = 12 inch

1 m = 100 cm

1 foot = 30cm

1 Inch = 2.5cm

1 Inch = 0.08foot

OUTPUT:

This output is checked and verified. The time complexity of this program is O(n).

Leave a Reply

Your email address will not be published. Required fields are marked *

Close Bitnami banner
Bitnami