#include <iostream>
using namespace std;
// floyd's triangle pattern problem
int main() {
int n = 5;
int num = 1;
// outer loop - rows
for(int i= 1; i<= n; i++){
// inner loop - each rows
for(int j =1; j <= i; j++){
cout << num++ << " ";
}
cout << endl;
}
return 0;
}
OUTPUT-
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
No comments:
Post a Comment