Advertisement
thenewboston

C Programming Tutorial - 57 - Return Values

Aug 23rd, 2014
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int calculateBonus(int yearsWorked);
  5.  
  6. int main()
  7. {
  8.     int buckysBonus = calculateBonus(14);
  9.     int emmasBonus = calculateBonus(3);
  10.  
  11.     printf("Bucky gets $%d \n", buckysBonus);
  12.     printf("Emma gets $%d \n", emmasBonus);
  13.  
  14.     return 0;
  15. }
  16.  
  17. //need to say what type of data you want back
  18. int calculateBonus(int yearsWorked){
  19.     int bonus = yearsWorked * 250;
  20.  
  21.     if(yearsWorked>10){
  22.         bonus += 1000;
  23.     }
  24.  
  25.     return bonus;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement