C Foundation

What is C? C Compiler Installation C Extensions C Compiler C Interpreter C Program Structure

C Basics

C Keywords C Data Types C Identifiers C Variables C Constant C Escape Sequences C Constant and Volatile C Typecast

Operators

What is Operator C Comma Operator C Arithmetic Operators C Relational Operators C Logical Operators C Bitwise Operators C Conditional Operators C : : Operator C Operator Priority

Basic IO's

Basic IO's C Formatted Functions C Unformatted Functions C Common Functions

Control Statements

What is Control Statement C if Statement C if else Statement C Nested if Statement C Else if Statement C Break Statement C Continue Statement C Switch Statement C Goto Statement

Looping

What is Control Loop C for Loop C Nested for Loop C while Loop C Nested while Loop C do while Loop C Nested do while loop

Functions

What is Function C User Defined Functions C Recursion C Passing Parameters

Scope

Scope C Local Scope C Global Scope

Storage Classes

What is Storage Class C Auto C Extern C Static C Register

Array

What is Array C One Dimensional Array C Two Dimensional Array C Multi Dimensional Array C Arrays Of Strings

String

What is String C String Functions

Pointer

What is Pointer C Pointers Arithmetic C Pointer to Pointer C Pointers and Arrays C Pointers and Strings C Pointer to Functions Void Pointers Null Pointers C Null and Void Pointer

Structure

What is Structure C Struct within Struct C Array within Structure C Pointer to Structure C Structure and Function C Enum C Bitfield Structure C Type def

Union

What is Union

Files

What is File C read a file C write a file C File Handling C Error Handling C Low Level Disk I/O C Other file functions

Memory Allocation

What is Memory Allocation C Malloc() C Calloc() C Free() C Realloc() C Coreleft()

C Reference

All ASCII Code Basic C Questions

C Interview

C Interview Sets All Star Patterns All Number Patterns All Alphabet Patterns All Series Patterns
The ones who are crazy enough to think they can change the world are the ones who do.
- Steve Jobs

C Multi Dimensional Array

What Is Multi Dimensional Array?

An array having more than one subscript or dimension is known as multi dimensional array i.e) int arr[3][3]. Multi dimensional arrays are also known as arrays of arrays or matrix.

c two dimensional array

Syntax - Multi Dimensional Array

  • Two Dimensional array requires two subsript variables
  • In the following syntax size1 represents no of rows whereas size2 represents no of columns.
Syntax
data-type varname [size1][size2];

Why Using Multi Dimensional Array?

Consider a specific example. Suppose that you have a extreme interest in the whether, and you are intent on recording the temperature each day at 2 separate geographical locations throughout the year. After you have sorted out the logistics of actually collecting this information, you can use an array of 2 elements corresponding to the number of locations, where each of these elements in an array of 4 elements to store the temperature values.

Program - Multi Dimensional Array

multi-dimensional-array.c
#include <stdio.h>
int main()
{
float temp[2][4] = {{12.31, 14.36, 13.4, 12.4}, {11.2, 11.24, 14.2, 12.5}};
int i, j;
for(i = 0; i < 2; i++)
{
for(j = 0; j < 4; j++)
{
printf("\nTemperature @ location %d ---> %f (%d time) ",i+1, temp[i][j] ,j+1);
}
}
return 0;
}
  • Temperature @ location 1 ---> 12.31 (1 time)
  • Temperature @ location 1 ---> 14.36 (2 time)
  • Temperature @ location 1 ---> 13.4 (3 time)
  • Temperature @ location 1 ---> 12.4 (4 time)
  • Temperature @ location 2 ---> 11.2 (1 time)
  • Temperature @ location 2 ---> 11.24 (2 time)
  • Temperature @ location 2 ---> 14.2 (3 time)
  • Temperature @ location 2 ---> 12.2 (4 time)

Note:

The above program clearly demonstrates the concept of two dimensional array.

Report Us

We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.

Report

We to update you