63 800
Assignments Done
99,5%
Successfully Done
In August 2018

Answer to Question #13575 in C++ for mohannaik

Question #13575
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..
Expert's answer
#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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions