Answer to Question #278069 in C for Cram

Question #278069

Burning Bridges

by CodeChum Admin

After getting out of the strange dimension, you feel like you have to cover up your path and close the exit so that nothing strange can follow you back.


Instructions

  1. Change the value of of the element located in the array index indicated by the int variables “exitCol” and “exitRow” to ‘0’.
  2. Print out the 2D array with each element per row separated by a space and each column separated by a line.


Input

Two ints separated by a space

0·0

Output

5x5 array with each sub array in a new line and each element separated by a space

0·1·1·1·1
1·1·1·1·1
1·1·1·1·1
1·1·1·1·1
1·1·1·1·1


-----------fill up the code---------------

#include<stdio.h>


int main() {

    int exitRow,exitCol;

    scanf("%d %d", &exitRow,&exitCol);

    int row_col[5][5] = {{1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,1}};

    


    return 0;

}


1
Expert's answer
2021-12-11T01:57:45-0500
#include <stdio.h>

int main() 
{
  int exitRow, exitCol;
  scanf("%d %d", &exitRow, &exitCol);
  int row_col[5][5] = {
    { 1, 1, 1, 1, 1 },
    { 1, 1, 1, 1, 1 },
    { 1, 1, 1, 1, 1 },
    { 1, 1, 1, 1, 1 }
    { 1, 1, 1, 1, 1 }
  }
  if (exitRow < 5 && exitCol < 5) {
    row_col[exitRow][exitCol] = 0;
  }
  for (int i = 0; i < 5; i = i + 1) {
    for (int j = 0; j < 5; j = j + 1) {
      printf("%d ", row_col[i][j]);
    } printf("\n");
  }
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS