Blogger news

Followers

Monday, July 21, 2014
#include<stdio.h>
#include<conio.h>

void main()
{
            /*col,row variables are used to store number of columns and rows respectively,
            mat is a two dimensional array is used to store the matrix, i,j is used as an indexing the elements from matrix*/
            int col,row,mat[100][100],i,j;
                        clrscr();   //clear the screen
           
printf(“enter the number of rows \n”);
            scanf(“%d”,&row);
           
            printf(“enter the number of coloumns \n”);
            scanf(“%d”,&col);
           
            printf(“number of rows:%d ,number of columns:%d”,row,col);

            printf(“enter the value of matrix \n”);
           
            for(i=0;i<row;i++)  //outer loop represents to the row
                        for(j=0;j<col;j++) // inner loop represents to the column
                                    scanf(“%d”,&mat[i][j]);

            printf(“your matrix is ….\n”);
           
            //following code is used to print each elements of matrix in row wise
            for(i=0;i<row;i++)
            {
                        for(j=0;j<col;j++)
                        {
                                    Printf(“%d\t”,mat[i][j]);
                        }
                        printf(“\n”);
            }
            getch();
}

0 comments: