Sunday, November 10, 2019

                                     E-BOX    

                               BASICS OF C PROGRAMMING   


Conditional Statements :-  Code Analysis

 PROBLEM -10:

                                                                LIFT I

 

The Personalized Gifts store is in the nth floor.


Sita gets into a lift in the ground floor.



The lift that Sita gets in does not stop in all floors. It stops in only 3 floors numbered n1, n2 and n3.

She wants to get down in the floor that is closest to n. If there are 2 choices, she always prefers to climb down the stairs rather than climbing up.

Help Sita in deciding the floor she should get down from the lift.

 

Input and Output Format:

Input consists of 4 integers corresponding to n, n1, n2 and n3.  [n1<n2<n3]

Output consists of an integer that corresponds to the floor number where she would get down.

 

Sample Input 1:

10

4

8

15

Sample Output 1:

8

 

Sample Input 2:

10

4

8

12

Sample Output 2:

12



SOLUTION :


INPUT 1   INPUT 2    INPUT 3   INPUT 4  INPUT 5   INPUT 6   INPUT 7

20             20              50             30            40            25             12

19             12              40             17            24            19             10

22             19              45             32            39            22             14

27             27              49             25            41            26             33












No comments:

Post a Comment

                                                 E-BOX                                                     BASICS OF C PROGRAMMING       i -...

https://amzn.to/2LAmadv