Hello, I have the following code in C
#include <stdio.h>
void main(void)
{
int num, cociente, a, b, c, d;
printf ("Evaluación de expresiones\n\n");
a = 10; b = 4; c = 5; d = 1; num = 0;
cociente = (num = a*b)/(num + c + d);
printf("Cociente vale %d\n", cociente);
printf("num vale %d\n", num);
printf("\n\nTerminación normal del programa.\n");
}
I would like to know why the value of 0 is being printed in quotient, I know that the parentheses operator has higher priority and if there are two it is executed from left to right, then the first one is (num = a*b)
if this parenthesis has priority I assume that must solve what is inside first, as there is an assignment and a multiplication, multiplication has higher priority and is solved first, then the assignment is made to num, being within the first parenthesis the variable num and with value of 40.
later the second parenthesis is solved, if num is 40 it is added with c + dy and a value of 46 is left in the second parenthesis, then the division between the two values is solved, 46/40, once solved is assigned the result to quotient.
Could you explain to me where my analysis error is, Thanks in advance