Answer to Question #278071 in C for Cram

Question #278071

Journey to Another Dimension

by CodeChum Admin

Somehow, in some way, you find yourself in a dimension within a dimension. Traverse the dimension and look for the exit!

Instructions:


Instructions

  1. Go through the 2D array and search for the array index containing the int value named “exit”.
  2. Print the indices with one space in between the column and row index.

Input

A single int input

1

Output

2 int outputs separated by a space

0·0




---------------to fill up code--------------------


#include<stdio.h>


int main() {

    int exit;

    scanf("%d", &exit);

    

    int col_row[5][5] = {{1,2,3,4,5},{6,7,8,9,10},

                        {11,12,13,14,15},{16,17,18,19,20},{21,22,23,24,25}};

    

    

}


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

int main() 
{
  int exit;
  scanf("%d", &exit);

  int col_row[5][5] = {
      { 1, 2, 3, 4, 5 },
      { 6, 7, 8, 9, 10 },
      { 11, 12, 13, 14, 15 },
      { 16, 17, 18, 19, 20 },
      { 21, 22, 23, 24, 25 }
  };
  
  for (int i = 0; i < 5; i = i + 1) {
    for (int j = 0; j < 5; j = j + 1) {
      if (col_row[i][j] == exit) {
        printf("%d %d\n", i, j);
        return 0;
      }
    }
  }  
  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