TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C Tutorials

C Two-Dimensional Arrays

Overview

A Two-Dimensional array is an array of dimension 2 (we can also call a 2D Array) a collection of elements accessed using two subscript expressions. For example, let’s call them rows and cols. A two-dimensional array is also called an array of single-dimensional arrays.

Declare 2D Array

The general syntax to declare 2D Array is:

<data type> <array name>[rows][cols];

int arr[2][2];

The array index in both dimensions starts with 0.

Example

#include<stdio.h>
void main(void){
// 2D Array declaration
int arr[2][2];
int i,j;
printf(“Enter Array elements:= “);
for(i = 0;i<2;i++){
for(j=0;j<2 ;j++) {
scanf(ā€œ%dā€,&arr[i][j]); }
}

for(i = 0;i<2;i++){
for(j=0;j<2;j++) {
printf(“Array element = %d\n”,arr[i][j]);
}
}

}

Related Posts

C Language Characteristics

C Tutorials /

C Language Characteristics

C Source Code .c File

C Tutorials /

C Program Files & Formats

GNU Compiler Collection GCC

C Tutorials /

C Compilers

C Pointers

C Tutorials /

C Pointers

Declare C Arrays

C Tutorials /

C Arrays

‹ C Arrays› C Pointers

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version