Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Introduction [cont'd]
Input Output Functions [cont'd]
Structures and Unions [cont'd]
# Preprocessor [cont'd]
Two Dimensional in Arrays of Programming in C
1882 Views
Two Dimensional 
If set of values stored in one variable by two index or subscript, which is called as two dimensional array.
Program
#include
void main(){
    int a[2][2],b[2][2],c[2][2];
    int i,j;
    printf("Matrix addition\n");
    //Assign value for a matrix
    a[0][0] = 5; a[0][1] = 7;
    a[1][0] = 3; a[1][1] = 4;
    //Assign value for b matrix
    b[0][0] = 4; b[0][1] = 2;
    b[1][0] = 7; b[1][1] = 8;
    //Matrix Addition
    for (i=0;i<2;i++)
        for (j=0;j<2;j++)
            c[i][j] = a[i][j] + b[i][j];
    //Displaying c matrix
    for (i=0;i<2;i++){
        for (j=0;j<2;j++){
            printf("%d\t",c[i][j]);
        }
        printf("\n");
    }
}
Output 
Matrix Addition
9 9
10 12
Next Topics
Next lessons of current book.
Previous Topics
Previous lessons of current book.
Looping Statements of Programming in C
Looping Statements of Programming in C
Looping Statements of Programming in C
Best Lessons of "Programming in C"
Top lessons which are viewed more times.
Structures and Unions of Programming in C
Input Output Functions of Programming in C
Structures and Unions of Programming in C
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details