Thursday, 21 June 2012

write a c program to accept m*n matrix from user & display the element of a given matrix by using function


/*write a c program to accept m*n matrix from user & display
the element of a given matrix by using function */
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n;
void matrix(int,int);
clrscr();
printf("enter the rows and coloumn");
scanf("%d%d",&m,&n);
matrix(m,n);
getch();
}
void matrix(int m, int n)
{
int a[10][10],i,j;
printf("enter the element of matrix");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\ndisplay of matrix :\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("\t%d",a[i][j]);
}
printf("\n");
}
}
/*enter the rows and coloumn3 2
enter the element of matrix1 2                                                
4 5                                                                            
7 8                                                                            
                                                                               
display of matrix :                                                            
        1       2                                                              
        4       5                                                              
        7       8                                                              
   */                                                

No comments: