64 648
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #19215 in C++ for baby_dawn

Question #19215
write a C++ function clip (lo,x,hi) that returns lo if x is less than lo; hi if x is greater than hi; and x otherwise for this problem you can assume that lo<hi.
Expert's answer
#include <stdio.h>
#include <conio.h>

int clip(int lo, int x, int hi)
{
if (lo < hi)
{
& if (x < lo)
& return lo;
& if (x > hi)
& return hi;
}
return x;
}

void main()
{
printf("%d\n", clip(8, 2, 11));
printf("%d\n", clip(2, 9, 6));
printf("%d\n", clip(5, 1, 4));
printf("%d\n", clip(7, 8, 10));
getch();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions