Increment and Decrement operators [duplicate]

-1

Why it did not add the value of variable 1, with 1 more in the first printf.

int numero = 1;
printf("Conteudo armazenado na variavel: %d\n", numero++); /*(por que aqui da resultado 1? não estou pedindo para ele somar?)*/
printf("Conteudo armazenado na variavel: %d\n", numero++);
    
asked by anonymous 07.08.2018 / 22:56

1 answer

2

I suggest you look for the difference between ++ x and x ++ link

Ex:

x = 1;

With x ++ it prints the value 1 and only in the 2nd print it prints 2

If it is ++ x it will print 2, because it will add first

    
07.08.2018 / 22:59