Increment and Decrease Operators

Asked

Viewed 41 times

-1

Why didn’t it add up the value of variable 1 , plus 1 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++);

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 prints 2

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.