2 Dimension Array

 #include <stdio.h>

int main()
{
    int matrice[2][3]={{1,2,3},  //1.row 2.column
                       {4,5,6}}; //initialization of array of name "matrice" of 2 row and 3 columns with values
    //accessing values of the array matrice[]
    printf("%d",matrice[0][0]);
    return 0;
}

//--------------------------------------------------

//using for loop for giving values to the array
/*#include <stdio.h>
int main()
{
    int i,j;
    int matrice[2][3];// 1.row 2.column
    for(i=0;i<2;i++) //row number loop
    {
        for(j=0;j<3;j++)//row number loop
        {
            printf("enter %d%d value of matrice:",i,j);
            scanf("%d",&matrice[i][j]);
        }
    }
    printf("\nthe values are\n");
    for(i=0;i<2;i++)//row number loop
    {
        for(j=0;j<3;j++) //column number loop
        {
            printf("matrice[%d][%d]=%d\n",i,j,matrice[i][j]);
        }
    }

    //representing values like matrice
    printf("\nthe values are represented like matrice\n");
    for(i=0;i<2;i++)//row number loop
    {
        for(j=0;j<3;j++) //column number loop
        {
            printf("%d ",matrice[i][j]);
        }
        printf("\n");
    }
   
    return 0;
}*/

Comments

Popular posts from this blog

Tokens in C

Steps taken by a compiler to execute a C program

Variables and Data Types in C