Monday, June 18, 2012

To print a matrix of order nXm


/* Program to print a matrix of order nXm */

#include<stdio.h>

#include<conio.h>

void main()

{

  int arr[100][100],n,m,i,j;

  clrscr();

  printf("Enter the number of rows and columns:\n");

  scanf("%d%d",&n,&m);

  printf("\nEnter the elements-->\n");

  for(i=0;i<n;i++)

  {

    for(j=0;j<m;j++)

    {

      scanf("%d",&arr[i][j]);

    }

  }

  printf("\n\nMATRIX:\n");

  for(i=0;i<n;i++)

  {

    for(j=0;j<m;j++)

    {

      printf("\t%d",arr[i][j]);

    }

    printf("\n");

  }

  getch();

}

 

OUTPUT

 

Enter the number of rows and columns:

4

3

 

Enter the elements-->

24

26

32

42

68

72

10

30

66

12

78

90

 

 

MATRIX:

        24      26      32

        42      68      72

        10      30      66

        12      78      90

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.