Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Declare a two dimensional array initialized as follows: int A[4][4] = { {10,11,1

ID: 3883186 • Letter: D

Question

Declare a two dimensional array initialized as follows: int A[4][4] = { {10,11,12,13), /* initializers for row indexed by 0 */ indexed by 1 */ {14,15,16,17}, /* initializers for row indexed by 1 */ {18,19,20,21}: /* initializers for row indexed by 2 */ {22,23,24,25}: } /* initializers for row indexed by 3 */ Write a program using pointer notation (instead of array notation) to access array elements. For each element, compute the sum of the remainders for each element is divided by 2, 3 and 5 respectively, and print the results in matrix format without creating any new array. For example, the first element of A is 10. Your program will calculate 10%2+10%3+10%5=1, and print 1 as the first element in row one on your screen.

Explanation / Answer

#include<iostream>

using namespace std;

int main(){

int A[4][4] = { {10,11,12,13},{14,15,16,17},{18,19,20,21},{22,23,24,25}};

for(int i=0;i<4;i++){

for(int j=0;j<4;j++){

*(*(A+i)+j) = *(*(A+i)+j)%2+*(*(A+i)+j)%3+*(*(A+i)+j)%5;

cout << *(*(A+i)+j) << " ";

}

cout << endl;

}

}

OUTPUT:

1 4 2 5

6 1 2 5

3 6 2 2

3 6 4 2

The name of the array gives the starting address of the array.

An array element A[i] can be acessed by adding its index to the array that is A+i.

* is used to acess the values at that address.

A[i] can be accessed using *(A+i)

similarly A[i][j] can be accessed using *(*(A+i)+j)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote