hello everyone,
I've tried to construct a nested while loop and for the nested loop the value output isn't returning to 0 at the beginning of the new loop. How might I fix this. Also, the final return value of successful vs unsuccessful simulations is wrong but also inconsistent. I would appreciate any help offered to solve either problem.
Code:
int main(){
int flag = 1;
int days, failure,run=0, success, adjustments, simulations, trial=0;
printf("How many days did we use the simulator?\n");
scanf("%d", &days);
while (flag){
(trial++);
printf("How many simulations did we run on day %d?\n", trial);
scanf("%d", &simulations);
int tag=1;
while (tag){
(run++);
printf("How many adjustments were needed for run #%d?\n", run);
scanf("%d", &adjustments);
if (run == simulations)
tag =0;}
if (adjustments >= 5)
failure=run;
printf("Day #%d: There were %d successful simulations.\n", trial, success);
printf("\n");
if (trial == days)
flag = 0;}