thenewboston

C Programming Tutorial - 37 - Absolute Value with abs

Aug 22nd, 2014
372
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. #include <ctype.h>
  4. #include <string.h>
  5. #include <math.h>
  6.  
  7. int main()
  8. {
  9.     int year1;
  10.     int year2;
  11.     int age;
  12.  
  13.     printf("Enter year \n");
  14.     scanf(" %d", &year1);
  15.  
  16.     printf("Enter another year \n");
  17.     scanf(" %d", &year2);
  18.  
  19.     age = year1 - year2;
  20.     printf("%d \n", age);
  21.     age = abs(age);
  22.     printf("%d \n", age);
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment