by Dinesh Thakur Category: C Programming (Pratical)

This is C program where user asks to trace a matrix with giving the order of matrix and print it. Here user declares variables that are mandatory for storing the value with it. Some variables are array type to holding value multiple. User asks to enter the no. of rows and columns as order of matrix. And then enters a number then after user varies the loop statement for situation handling to print a matrix. Nested loop statements are used in this program to elaborate the condition itself for tracing the matrix. A printing message for the matrix elements. And then display matrix on the screen as a result.

Problem Statement:

This is C Program that ask user to trace a matrix.

  1. Declaring the variable.
  2. Using loop statement.
  3. Display result on the screen.

Here is C source code for tracing a Matrix. The output of this program shown below. 

#include<stdio.h>

void main()
{
     int i,j,a[10][10],m,n;
     clrscr();
     printf("Enter no: of Rows : ");
     scanf("%d",&m);
     printf("Enter no: of Columns : ");
     scanf("%d",& n);
     printf("Enter a Number : ");
     for(i=0;i<m;i++)
         {
           for(j=0;j<n;j++)
               {
                  scanf("%d",&a[i][j]);
               }
         }
                  printf("\nElements are :\n");
                  for(i=0;i<m;i++)
                      {
                        for(j=0;j<n;j++)
                            {
                                printf("%d  ",a[i][j]);
                            }
                                printf("\n");
                      }
                                getch();

Trace a Matrix

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content