+ 3
How to print the following output using for loop
1 2 3 4 5 6 7 8 9 10
8 Respuestas
+ 8
@faisal i think the answer was asked in java....
+ 5
Here Is The Code, Wait I'm Writing...
#include <iostream>
using namespace std;
int main()
{
int row, number = 1;
cout << "Enter number of rows: ";
cin >> row;
for(int i = 1; i <= row; i++)
{
for(int j = 1; j <= i; ++j)
{
cout << number << " ";
++number;
}
cout << endl;
}
return 0;
}
+ 5
Thank you @ Justin Hill
+ 4
int count=1;
for(int i=0; i<5;i++){
for(int j=0; j<i; j++){
System.out.print(count + " ");
count++;
}
System.out.println();
}
+ 4
So sorry 😉, I don't know java & I also didn't see that java tag
+ 4
@chirag you are right - I didn't see that 😊
+ 4
No problem Faisal Reza
Thank you
+ 2
check This Out