---
title: "How can I write a C code for a (2D) array?"  
description: "How can I write a C code for a (2D) array?"  
author: "Mukul Goenka"  
published: 2021-11-10  
updated: 2021-11-10  
canonical: https://www.mindstick.com/forum/156820/how-can-i-write-a-c-code-for-a-2d-array  
category: "java"  
tags: ["java", "programming language"]  
reading_time: 2 minutes  

---

# How can I write a C code for a (2D) array?

How can I write a C [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) for a (2D) [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net)?

## Replies

### Reply by Ravi Vishwakarma

```
#include <stdio.h>#define ROW 2  // it is row value of array #define COL 2  // is is column value of arrayint main(){        int ary[ROW][COL]; // array declaration        // enter value in array    for(int i = 0; i<ROW; i++)    {        printf('Enter %d ROW values : \n',i+1);        for(int j = 0; j<COL; j++)        {            printf('\tEnter %d ROW of %d column value : \n',(i+1),(j+1));            scanf('%d',&ary[i][j]); // enter value in array one by one         }        }        //print value from array    printf('\nYou are enter these values \n');    for(int i = 0; i<ROW; i++)    {        for(int j = 0; j<COL; j++)        {            printf('%5d',ary[i][j]);        }            printf('\n');    }}
```

Output.

```
Enter 1 ROW values :
        Enter 1 ROW of 1 column value :
45
        Enter 1 ROW of 2 column value :
63
Enter 2 ROW values :
        Enter 2 ROW of 1 column value :
95
        Enter 2 ROW of 2 column value :
63
You are enter these values
   45   63
   95   63
```


---

Original Source: https://www.mindstick.com/forum/156820/how-can-i-write-a-c-code-for-a-2d-array

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
