Share

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

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

Java

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

Python

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

C++

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

Javascript

let size = 5;
    for (var i = 0; i < size; i++){ 
         let eachLine = ''// iterates rows
         for (var j = 0; j < size; j++){ // iterates * in row
             eachLine += "* "
         }
           console.log(eachLine); 
}