Answer to Question #38709 in C++ for Verasak Sitawan

Question #38709
B. Modify the InBetween program so that the user must reenter the second value so it is
guaranteed to be higher than the first entered value. Save the file as InBetween2.cpp.
1
Expert's answer
2014-01-28T10:03:33-0500
#include <stdio.h>


int main () {
int lower, upper;

scanf("%d %d", &lower, &upper);

if ( lower > upper ) {
printf("First number has to be smaller than the second one");
return 0;
}

for (int i = lower + 1; i < upper; i++) {
printf("%d ", i);
}
printf("
");
return 0;
}

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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS