Nayyab F.

asked • 05/27/21

i want to get unique solution of the question and i am mentioning question in description box

Take a sorted array of 15 elements of type int and a value x from user, you need to find the ceiling

and floor of x. The ceiling of x is the smallest element in array greater than or equal to x, and the

floor is the greatest element smaller than or equal to x. Assume than the array is sorted in

ascending order. Write functions to find floor and ceiling of x from the given array.

Examples :


For example, let the input array be {1, 2, 8, 10, 10, 12, 19}

For x = 0: floor doesn't exist in array, ceil = 1

For x = 1: floor = 1, ceil = 1

For x = 5: floor = 2, ceil = 8

For x = 20: floor = 19, ceil doesn't exist in array

Nayyab F.

I want solution in c++ language
Report

05/27/21

2 Answers By Expert Tutors

By:

Biruk A. answered • 05/28/21

Tutor
New to Wyzant

A Programing enthusiastic and a self taught web developer

Patrick B. answered • 05/27/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.