add range check
This commit is contained in:
18
src/LAB3.c
18
src/LAB3.c
@@ -44,7 +44,7 @@ double do_while_fn(Context* ctx)
|
|||||||
r += iter_fn(ctx->x, i);
|
r += iter_fn(ctx->x, i);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
while (i <= ctx->i);
|
while (i <= ctx->n);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -57,8 +57,20 @@ void lab_3()
|
|||||||
printf("Enter [x]: ");
|
printf("Enter [x]: ");
|
||||||
READ_EXACT("%lf", ctx.x);
|
READ_EXACT("%lf", ctx.x);
|
||||||
|
|
||||||
printf("Enter [N]: ");
|
do
|
||||||
READ_EXACT("%u", ctx.n);
|
{
|
||||||
|
printf("Enter [N]: ");
|
||||||
|
READ_EXACT("%u", ctx.n);
|
||||||
|
|
||||||
|
if (ctx.n < ctx.i)
|
||||||
|
{
|
||||||
|
printf("N could not be less than I=1, try again\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while(1);
|
||||||
|
|
||||||
LoopFn* loop_fn;
|
LoopFn* loop_fn;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user