Program to print pattern as shown in sample output.
Sample Input4
Sample Output
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
Solution in | C | JAVA | PYTHON |
---|
#include<stdio.h>
int main() {
int n;
scanf("%d",&n);
for(int row=1;row<=n;row++){
for(int col=1;col<=n;col++){
printf("%d",col);
if(col<=n-1){
printf(" ");
}
}
if(row<=n-1){
printf("\n");
}
}
}
int main() {
int n;
scanf("%d",&n);
for(int row=1;row<=n;row++){
for(int col=1;col<=n;col++){
printf("%d",col);
if(col<=n-1){
printf(" ");
}
}
if(row<=n-1){
printf("\n");
}
}
}