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