fork download
  1. /******************************************************************************************
  2. * Name: Marcelo Vargas
  3. * Chapter 2 Homework
  4. * Class: CSC5
  5. * #5
  6. *
  7. * Average Values
  8. *
  9. * This program is going to calculate the average of the following variables
  10. * 28,32,37,24 and 33
  11. * _________________________________________________________________________________________
  12. * INPUT
  13. * num1 :first value (28)
  14. * num2 :second value (32)
  15. * num3 :third value (37)
  16. * num4 :fourth value (24)
  17. * num5 :fifth value (33)
  18. *
  19. * OUTPUT
  20. * Average = :the average of the values num1,num2,num3,num4,num5
  21. *******************************************************************************************/
  22. //importing "iostream" from stream library
  23. #include <iostream>
  24. using namespace std;
  25.  
  26. //Declare variables
  27. int main(){
  28. int num1 = 28;
  29. int num2 = 32;
  30. int num3 = 37;
  31. int num4 = 24;
  32. int num5 = 33;
  33.  
  34. //Adding the values together
  35. int sum= num1 + num2 + num3 + num4 + num5;
  36.  
  37. //calculating the average of the values
  38. int average = sum % 5;
  39.  
  40. //Displayes the average of the values
  41. cout<< "The average of the Variables is " << average;
  42.  
  43. return 0;
  44. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
The average of the Variables is 4