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

5th Nov 2019, 11:59 PM
SaAd Ali
SaAd Ali - avatar
1 Antwort
+ 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
6th Nov 2019, 2:33 AM
Avinesh
Avinesh - avatar