Answer to Question #13575 in C++ for mohannaik
display this in your output
1
2 3
4 5 6
7 8 9 10
11 12 13 14
.
.
.
.....................................n
The value of have to be given during execution of the program..
1
2012-08-30T09:44:16-0400
#include <iostream>
using namespace std;
int main (){
int k = 0;
int p = 2;
cout<<"Enter n, please: ";
int n;
cin>>n;
cout<<endl;
for (int i = 1 ; i < n+1 ; i++){
& cout<<i<<' ';
& if (k == 0){
& k = p;
& p++;
& cout<<endl;
& }
& k--;
}
system("pause");
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment