Question: Using C programming and UNIX/Linux terminal. PLEASE DON'T FORGET TO EXPLAIN THE LAST PART! /* * Program for lab8q3.c */ #include /* * function to

Using C programming and UNIX/Linux terminal.

PLEASE DON'T FORGET TO EXPLAIN THE LAST PART!

Using C programming and UNIX/Linux terminal. PLEASE DON'T FORGET TO EXPLAIN THE

/* * Program for lab8q3.c */ #include

/* * function to print element [i][j] of an array of type int** * of dimension [num_rows][num_cols]. Address to the start of the * contiguous array is provided by argument vec_p. */ void print_value( int *vec_p, int num_rows, int num_cols, int i, int j ) { int *elem_p;

if( i >= num_rows ) { fprintf( stderr, "row %d is out-of-bounds in [%d][%d] ", i, i, j ); return; } if( j >= num_cols ) { fprintf( stderr, "column %d is out-of-bounds in [%d][%d] ", j, i, j ); return; } // in the next statement, assign to elem_p the address of the element // we are interested in, element [i][j]. // To do this, use the formula for array access into a contiguously // allocated array shown in class. However, remember that in // arithmetic involving pointers, the compiler automatically // scales by size-of-pointed-to-type. You cannot use the '&' in // your formula/expression. elem_p = // replace this comment with the correct expression printf( "value of element [%d][%d] = %02d ", i, j, *elem_p ); }

int main( ){ int b[5][5] = { {0,1,2,4,5}, {10,11,12,13,14}, {20,21,22,23,24}, {30,31,32,33,34}, {40,41,42,43,44} };

int r, c;

for( r=0; r

print_value( (int *)b, 5, 5, 0, 5 ); print_value( (int *)b, 5, 5, 5, 0 ); print_value( (int *)b, 5, 5, 4, 3 );

return 0; }

Download lab8q3_incomplete.c from the moodle pages for this lab. (You do not have to show a log of this in lab8.txt.) It is a revision of example_60.c from class. There is one statement in the program that is incomplete. That statement calculates the address of the (ith, jth) component of an element in a 2D vector. In this question you need to provide the correct expression and complete the statement Note that you cannot use the unary & operator in your expression. The completed statement should only occupy a single line in the source file. Copy lab8q3_incomplete.c to lab8q3.c and, with a text editor, complete the partial statement in lab8q3.c as described above. (You do not need to show a log of your editing in lab8.txt.) Compile lab8q3.c using -Wall and -Wextra and run it. Make sure that the results are what they should be. Finally, produce a diff (1) of the two files (lab8q3_incomplete.c and lab8q3. c) to indicate your modification

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!