Advertisement
thenewboston

C Programming Tutorial - 14 - Calculating the Average Age

Aug 22nd, 2014
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     float age1, age2, age3;
  7.     float average;
  8.     age1 = age2 = 4.0;
  9.  
  10.     printf("Enter your age\n");
  11.     scanf("%f", &age3);
  12.  
  13.     average = (age1 + age2 + age3) / 3;
  14.     printf("\nThe average age of the group is %f", average);
  15.  
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement