C) Assume that the main contains the definition of the following variables and/or constants: int mat[NR][NC]; int i=0, j=0, "pi=&i, *pj=&j; Which of the following function calls contain errors? (Say...

This is not a graded question so please don't disregard it as if it is.Thank you in advance professor! Note: This is a THEORETICAL QUESTION and no code should be used for solving it.C) Assume that the main contains the definition of the following variables and/or constants:<br>int mat[NR][NC];<br>int i=0, j=0,

Extracted text: C) Assume that the main contains the definition of the following variables and/or constants: int mat[NR][NC]; int i=0, j=0, "pi=&i, *pj=&j; Which of the following function calls contain errors? (Say why) 1. moveIndexes (mat, &i, &j, NC); 2. moveIndexes (mat, pi, pj, NR); 3. moveIndexes (mat, *pi, *pj, NR); 4. moveIndexes (mat, i, j, NC); B 三 A) delta represents an increase or a decrease: of what? (Explain your answer) 1. of row? (Justify your answer) 2. of column? (Justify your answer) 3. other (What? Justify your answer) B) Given *rp=3 and *cp=4, delta=12, which values will be assigned to *rp and *cp at the end of function execution? (Justify your answer or show intermediate results) *rp = *cp = C) Which of the following function calls contain errors? (Say why) 1. moveIndexes (mat, &i, Ej,NC); 2. moveIndexes (mat, pi,pj,NR); 3. moveIndexes (mat, pi, *pj,NR); 4. move Indexes (mat, i,j, NC) ;
You are given the following function moveIndexes, where NR and NC are numerical constants. The function receives as<br>parameters rp and cp, two pointers to int. The goal of the function is to modify the values pointed by rp and cp as follows: if<br>rp and cp originally point to the indexes of a certain cell of the matrix, after function invocation they must point to the indexes of<br>a cell at a distance delta from the original one.<br>int movelndexes (int M[NR][NC], int *rp, int *cp, int delta) {<br>int i, j, *p, *p0;<br>i = *rp;<br>j = *cp;<br>if (i<0 || i>=NR || j<0 \[ j>=NC)<br>return 1; // error<br>nothing done<br>p0 = & (M[] [0]);<br>p = & (M[i [5]);<br>p = p+delta;<br>if (p < p0 || p > & (M[NR-1] [NC-1]))<br>return 1; // error - nothing done<br>

Extracted text: You are given the following function moveIndexes, where NR and NC are numerical constants. The function receives as parameters rp and cp, two pointers to int. The goal of the function is to modify the values pointed by rp and cp as follows: if rp and cp originally point to the indexes of a certain cell of the matrix, after function invocation they must point to the indexes of a cell at a distance delta from the original one. int movelndexes (int M[NR][NC], int *rp, int *cp, int delta) { int i, j, *p, *p0; i = *rp; j = *cp; if (i<0 ||="" i="">=NR || j<0 \[="" j="">=NC) return 1; // error nothing done p0 = & (M[] [0]); p = & (M[i [5]); p = p+delta; if (p < p0="" ||="" p=""> & (M[NR-1] [NC-1])) return 1; // error - nothing done "rp = (p – p0) / NC; "cp = (p - p0) % NC; return 0; Assume that NR and NC are equal to 10, that addresses are represented with 32 bits, and that sizeof(int) is equal to 4, Answer the following questions: A) delta represents an increase or a decrease: of what? (Explain your answer) 1. of row? 2. of column? 3. other (what?) B) Given *rp3D3 and cp=4, delta=12, which values will be assigned to rp and cp at the end of function execution? (Justify your answer or show intermediate results) C) Assume that the main contains the definition of the following variables and/or constants int mat [NR] [NC];
Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here