Hi
Below is a small piece of code posted to the board a few days ago, can some one explain to me what is happening to it??
I realise that it is increaseing by three but what makes 'i' print three idetical numbers but 'j' prints numbers sequentialy.
Are the two for's not the same??
#include <stdio.h>
int main(void)
{
int i, j ;
for (i = 1; i <= 3; i++)
for (j = 1; j <= 3; j++)
printf("%d ------ %d\n", i, j);
system("pause");
return 0;
}
the way the numbers are displayed seems to be controled by the 'i' for !!. If I alter the numbers in the for's 'i' I get
two diffrent displays but governed by what is in the 'i' for.
#include <stdio.h>
int main(void)
{
int i, j ;
for (i = 1; i <= 3; i++)
for (j = 1; j <= 6; j++)
printf("%d ------ %d\n", i, j);
system("pause");
return 0;
}
the code above gives :-
1 1
1 2
1 3
1 4
1 5
1 6
2 1
2 2ect,ect up to a count of three on the left. But six digits on the right.why does it not display six out puts on the right.If I put six in the 'i' for it displays six units(left and right)