I want to understand about the procedure of 'printf' function with postfix increment operator.
I debuged these codes and found something that each 'printf' function actives after the end of the while loop.
I expected the result is like these at the second while loop
0 x 0 = 0
1 x 1 = 1
2 x 2 = 4
3 x 3 = 9
but it was wrong
I want to know about flow of the arguments and why the result printed out like this. ;(
Sorry for my poor English and I hope you guys help me solve this problem. thank you.
#include<stdio.h>
int main(void)
{
int num1 = 0, num2 = 0;
//test while and postfix increment operator
//first while
while (num1 < 30)
{
printf("%d x %d = %d\n", num1++, num2++, num1 * num2);
//the results
//0 x 0 = 1
//1 x 1 = 4
//2 x 2 = 9
//3 x 3 = 16 ...
//the procedure of the printf function is from left to right?
//the flow of arguments is from left to right
}
//reset
num1 = 0, num2 = 0;
printf("\n");
//second while
while(num1 < 30)
{
printf("%d x %d = %d\n", num1, num2, (num1++) * (num2++));
//the results
//1 x 1 = 0
//2 x 2 = 1
//3 x 3 = 4
//4 x 4 = 9...
//the procedure of the printf function is from right to left?
//the flow of arguments is from right to left
//...why..?
}
return 0;
}