Pattern6
C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
int numbers,i,j,p=1;
printf("Enter the Number of rows:");
scanf("%d",&numbers);
for(i =0 ; i<numbers; i++)
{
for(j=0; j<numbers ; j++)
{
printf("%d ",p);
p++;
}
printf("\n");
}
}
Java Program
import java.util.Scanner;
public class Pattern_6 {
public static void main(String[] args) {
Scanner S = new Scanner(System.in);
System.out.print("Enter The number of Rows:");
int n = S.nextInt();
int p = 1;
for(int i =0 ;i <n; i++)
{
for(int j=0; j <n; j++)
{
System.out.print(p + " ");
p++;
}
System.out.print("\n");
}
}
}
Python Program
n = int(input("Enter number of rows: "))
k=1
for i in range(n):
for j in range(n):
print(k, end= " ")
k=k+1
print(" ")
0 Comments:
Post a Comment