0
Trying Floyd triangle but its give addition 3 in my code help me for figure out
int main(){ int no; cin>>no; int i ; int j,k; for (i = 1; i <=no; i++) { for (j = 0; j<i; j++) { cout<<i+j; for (k = 1; k<j;k++) { cout<<i+j+k; } } cout<<endl; } } Output: 1 23 3456
1 Answer
+ 1
#include <iostream>
using namespace std;
int main() {
int rows, i, j, num= 1;
cout<<"Enter number of rows: \n";
cin >> rows;
for(i=1; i <= rows; i++) {
for(j=1; j <= i; ++j) {
cout << num;
++num;
}
cout <<endl;
}
return 0;
}
Use this instead