2_Answers_8 - CIS 15BG Answers Chapter 8 Arrays Two...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS 15BG Answers Chapter 8 Arrays: Two Dimensional Arrays 1. Declare a 2D-array of integers, with 4 rows and 10 columns, and initialize all its elements to 0. Then assign 50 to the last element in the second from the last row and 99 to the first element in the second column. int table[4][10] = {0}; table[2][9] = 50; table[0][1] = 99; 2. Given the square two-dimensional array of integers shown below, what will be printed from the following program fragment? 50 11 12 13 20 80 22 23 30 31 25 33 40 41 42 10 for( r = 0; r < 4; r++ ) for( c = 0; c < 4; c++ ) if( r == c ) printf( %d , table[r][c] ); Output: 50 80 25 10 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CIS 15BG Answers Chapter 8 Arrays: Two Dimensional Arrays 3. Rewrite the fragment of code in Exercise 3 as a function then call it from main. Define two parameters: the 2D-array, table , and its actual size, n . Also, give a simpler and more efficient algorithm. #include<stdio.h> #define MAX_SIZE 100 void printDiagonal(int table[][MAX_SIZE], int n); int main( void )
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

2_Answers_8 - CIS 15BG Answers Chapter 8 Arrays Two...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online