Title | Practice problems arrays |
---|---|
Author | Nirav Patel |
Course | Introduction To Algorithmic Problem- Solving |
Institution | Queens College CUNY |
Pages | 4 |
File Size | 33.2 KB |
File Type | |
Total Downloads | 99 |
Total Views | 128 |
Professor Alex Ryba
Arrays problems...
Solutions to practice problems on arrays.
(1) Read the entries of an array of 10 integers from a user. Compute x as the average of the 10 entries and then compute the average of those entries that are greater than or equal to x. Print this final average. #include using namespace std; int main() { int a[10], c, count = 0; double total1 = 0, average1, total2 = 0, average2; cout a[c]; for (c = 0; c < 10; c++) total1 += a[c]; average1 = total1 / 10; for (c = 0; c < 10; c++) if (a[c] >= average1) { total2 += a[c]; count++; } average2 = total2 / count; cout...