Program to read ‘n’ number and print them in matrix terms in all orders - 100 Most Important C# Programs

100 Most Important C# Programs

54. Program to read ‘n’ number and print them in matrix terms in all orders.

Code:

# include <stdio.h>

# include <conio.h>

main( )

{

int i,n,c,p,q,r,k,a[20];

clrscr();

printf(“enter the array size”);

scanf(”%d”,&n);

printf(“enter the elements”);

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

scanf(“%d”,&a[i]);

i=1;

while(i<=n)

{

if(n%i==0)

{r

=i;

c=n/i;

k=1;

for(p=1;p<=r;p++)

{

for(q=1;q<=c;q++)

printf(“%d”,a[k++])

printf(“\n”);

}

i++;

getch( );

}