

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Homework about Double arrays and loops
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


College of Engineering Department of Computer Science and Engineering CMP120 – Introduction to computer science I Spring 2022 Homework 5: 2D arrays and functions Date: 24/March/ Due: 28/March/ 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:
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 (Rs4 and Cs4): 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