Question: How do I refactor my code (in a function) to replace the following nested if-else statements to a do-while loop in C code: int funciton()
How do I refactor my code (in a function) to replace the following nested if-else statements to a do-while loop in C code:
int funciton() { int x; printf("... "); scanf("%d%*c", &x);
if (x < 0) { printf("..."); exit(0);
} else if ((x < 1) || (x > 100)) {
printf("...");
function();
} else {
return x;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
