Reputation: 11
I'm new to C programming and I am practicing on making a matrix but it is kind of different. I must only enter 1 number (e.g) 5. then the result will be
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
The colums and rows are lined 5 times. Please send help.
#include<stdio.h>
main(){
int mat[10][10],i,j;
int num;
int nrows, ncols;
scanf("%d",&num);
for(i=1;i<=num;i++){
printf("%d",i);
for(i=1;i<=num;i++){
printf("%d",i);
}
}
}
Upvotes: 1
Views: 60
Reputation: 15035
Your current code is along the right lines, but:
j
you declared at the top\n
at the endAmended:
for(i=1;i<=num;i++){
for(j=1;j<=num;j++){
printf("%d",j);
}
printf("\n");
}
Upvotes: 1