Advertisement
thenewboston

C Programming Tutorial - 24 - Increment Operator

Aug 22nd, 2014
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int a = 5, b = 10, answer = 0;
  7.     answer = ++a * b; //added one to a AFTER the calculation
  8.     printf("a:%d \t b:%d \t answer:%d \n", a, b, answer);
  9.  
  10.     //reset variables
  11.     a = 5, b = 10, answer = 0;
  12.     answer = a++ * b; //added one to a BEFORE the calculation
  13.     printf("a:%d \t b:%d \t answer:%d \n", a, b, answer);
  14.  
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement