40代からのプログラミング_(初心者奮闘記)

プログラミングに関する学習メモ

前置 後置 インクリメント演算子

# prefix increment operator (e.g → ++x)
// first increases the value by 1 and then uses it
// increase then use.
 
# postfix increment operator (e.g → x++)
// first uses the value and then increases it by 1,
// use then increase.
 
# 実際のコードで視覚的に理解するほうが早い
 
{
    int i, j, k;
    i = 3;
     j =2*(i++);    // i=4,j=6
     k =2*(++i);    // i=5,k=10
}