Thread: loops not working, dont know why

1. loops not working, dont know why

hey y'all, right now my code is returning the number of scanned days for the second print line instead of starting at 1, then print line 2 is running an infinite loop. I'm not understanding why this is happening; any suggestions would be much appreciated. I'm very very new to C.

int days, success, adjustments, simulations, day, trial=0;

Code:
```    int i,j;
printf("How many days did we use the simulator?\n");
scanf("%d", &days);
for (i=0; i=days;i++){
printf("How many simulations did we run on day %d?\n", i);
scanf("%d", &simulations);
for(j=0; j=simulations; j++)
printf("How many adjustments were needed for run #%d?\n", simulations);

hey y'all, right now my code is returning the number of scanned days for the second print line instead of starting at 1, then print line 2 is running an infinite loop. I'm not understanding why this is happening; any suggestions would be much appreciated. I'm very very new to C.

int days, success, adjustments, simulations, day, trial=0;

Code:
```    int i,j;
printf("How many days did we use the simulator?\n");
scanf("%d", &days);
for (i=0; i=days;i++){
printf("How many simulations did we run on day %d?\n", i);
scanf("%d", &simulations);
for(j=0; j=simulations; j++)
printf("How many adjustments were needed for run #%d?\n", simulations);
You are doing assignments not tests for equivalencies! '==', NOT '='!

Also, you fail to test if the scanf() calls were successful! What if I typed "abc" in response to one of the prompts?

3. > for (i=0; i = days; i++)

Your test condition is an assignment and not a test condition as pointed out by @rstanley already.

Perhaps what you want is this

Code:
```for (i = 0; i < days; i++)
{
//...

for (j = 0; j < simulations; j++)
{
//...
}
}```