Share

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

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

Java

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

Python

for x in range(5,0,-1):
    for y in range(0,x):
        print("* ",end="")
    print()

C++

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

Javascript

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