Saturday, 2 April 2016

Compound Types (C++ Primer Plus Sixth Edition Solution Manual Question # 10)

Leave a Comment
Explanation:
Below mention code is compiled in Visual Studio 2015 and Code Blocks 13.12,output snap is attached.. If any problem you feel and you want some explanation feel free to contact us.

Code:

/**************************************************|
/*************C++ Programs And Projects************|
***************************************************/


/*
10. Write a program that requests the user to enter three times for the 40-yd dash
(or 40-meter, if you prefer) and then displays the times and the average.
Use an array object to hold the data. (Use a built-in array if array is not available.)
*/

#include <iostream>
using namespace std;

int main() {

       int arr[5];
       for (int i = 0; i < 5; i++){
              cout << "Enter the yard of " << i + 1<<" = ";
              cin >> arr[i];
       }
       int sum = 0;
       for (int i = 0; i < 5; i++){
              sum = sum + arr[i];
       }
       cout << "Average == " << sum/5;
       return 0;
}




Output:


Related Articles:

C++ Primer Plus Sixth Edition Complete Solution Manual 

C++ Books Solution

If You Enjoyed This, Take 5 Seconds To Share It

0 Questions: