fork download
  1. //Ryan Shahriyarpour CS1A Carl Argila CH2 HW Q:5
  2. //
  3. /*****************************************************************************
  4.  *
  5.  * Computing the Average of 5 Values
  6.  *
  7.  *
  8.  * *******
  9.  * The goal of the program is to find and compute the average of five values:
  10.  * 28, 32, 37, 24, and 33.
  11.  *
  12.  *
  13.  * To do this correctly, the program will compute:
  14.  * sum = num1 + num2 + num3 + num4 + num5
  15.  * average = sum / 5
  16.  *
  17.  *
  18.  * *******
  19.  *
  20.  * INPUT
  21.  * number 1 : 28
  22.  * number 2 : 32
  23.  * number 3 : 37
  24.  * number 4 : 24
  25.  * number 5 : 33
  26.  *
  27.  * OUTPUT
  28.  * average : The average of the five values
  29.  *
  30.  *****************************************************************************/
  31.  
  32. #include <iostream>
  33.  
  34. int main() {
  35. // Specify the numbers and assign them each to a variable
  36. int num1 = 28;
  37. int num2 = 32;
  38. int num3 = 37;
  39. int num4 = 24;
  40. int num5 = 33;
  41.  
  42. // Compute the sum as well as the average
  43. int sum = num1 + num2 + num3 + num4 + num5;
  44. double average = sum / 5;
  45.  
  46. // Now display what the output is
  47. std::cout << "The average is " << average << std::endl;
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
The average is 30