Write a C++ program that declares the following 2 arrays:        const int Rs = 8, Cs = 8;        double arr[Rs][Cs];        double arr_quarter[Rs / 4][Cs / 4];          //fill in the array with some data        for (int r = 0; r < Rs; r++)               for (int c = 0; c < Cs; c++)                      arr[r][c] = r * 8 + c;

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 1PP: (Statistics) a. Write a C++ program that reads a list of double-precision grades from the keyboard...
icon
Related questions
Question
 

Computer Science

Write a C++ program that declares the following 2 arrays:

       const int Rs = 8, Cs = 8;

       double arr[Rs][Cs];

       double arr_quarter[Rs / 4][Cs / 4];

 

       //fill in the array with some data

       for (int r = 0; r < Rs; r++)

              for (int c = 0; c < Cs; c++)

                     arr[r][c] = r * 8 + c;

Then:

  1. Print out the diagonal of arr
  2. Print out the anti-diagonal of arr
  3. Downsize arr by a factor of 4 (i.e. Rs/4 and Cs/4) and store the result in arr_quarter. Then print it out.
  4. Then upsize arr_quarter by a factor of four and store the result in arr and print it out.

 

Expected output:

Print Array:

0 1 2 3 4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23

24 25 26 27 28 29 30 31

32 33 34 35 36 37 38 39

40 41 42 43 44 45 46 47

48 49 50 51 52 53 54 55

56 57 58 59 60 61 62 63

 

Diagonal elements:

0 9 18 27 36 45 54 63

 

Anti-diagonal elements:

7 14 21 28 35 42 49 56

 

Downsize an array (quarter Rs and Cs):

Print Array:

0 4

32 36

 

Upsize an array (Rs*4 and Cs*4):

Print Array:

0 0 0 0 4 4 4 4

0 0 0 0 4 4 4 4

0 0 0 0 4 4 4 4

0 0 0 0 4 4 4 4

32 32 32 32 36 36 36 36

32 32 32 32 36 36 36 36

32 32 32 32 36 36 36 36

32 32 32 32 36 36 36 36

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning