Share

loop programming exercises in java, c++, python and javascript —01

Java

for(int i=1;i<=5;i++){
  	for(int j=1;j<=i;j++){
      	System.out.print("* ");
    }
  System.out.println();
		}

Python

for x in range(1,6):
    for y in range(1,x+1):
        print("* ",end="")
    print()

C++

for(int i=1;i<=5;i++){
		for(int j=1;j<=i;j++){
		cout<<" * ";
		}
		cout<<endl;

Javascript

for(let i=1; i<=6; i++){
   console.log("* ".repeat(i));
}