t805

Sum Of 3 Integers (Modular)

Sep 10th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int ReadNumber(int nth)
  4. {
  5.     int n;
  6.  
  7.     printf("Please enter number %d: ", nth);
  8.     scanf("%d%*c", &n);
  9.    
  10.     return(n);
  11. }
  12.  
  13. int CalculateSum(int n1, int n2, int n3)
  14. {
  15.     return(n1 + n2 + n3);
  16. }
  17.  
  18. void DisplayResults(int sum)
  19. {
  20.     printf("The sum is %d\n", sum);
  21.    
  22.     return;
  23. }
  24.  
  25. int main()
  26. {
  27.     int n1, n2, n3;
  28.     int sum;
  29.  
  30.     n1 = ReadNumber(1);
  31.     n2 = ReadNumber(2);
  32.     n3 = ReadNumber(3);
  33.  
  34.     sum = CalculateSum(n1, n2, n3);
  35.     DisplayResults(sum);
  36.  
  37.     return(0);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment