Monday, 25 March 2019

CP : 2 D Array : accept 9 numbers in form of matrix and display in matrix form.

Que: Write a program to accept 9 numbers in the form of matrix and display in matrix form.

A matrix is the rectangular array of numbers. 


Code:
#include <stdio.h>
void  main()
{
    int array [3][3];
    int i,j;

         printf("Input elements in the matrix :\n");
  for(i=0;i<3;i++)
  {
      for(j=0;j<3;j++)
      {
      printf("element - [%d],[%d] : ",i,j);
      scanf("%d",&array [i][j]);
      }
  }

    printf("\nThe matrix is : \n");
  for(i=0;i<3;i++)
  {
      printf("\n");
      for(j=0;j<3;j++)
           printf("%d\t",array[i][j]);
  }
 printf("\n\n");
}

Output:






No comments:

Post a Comment

LAB 7 Arduino with Seven Segment Display || Arduino Tutorial || Code and Circuit Diagram || Project

  LAB 7 Arduino with Seven Segment Display || Arduino Tutorial || Code and Circuit Diagram || Project Dear All We will learn how to Connec...