60 316
Assignments Done
98%
Successfully Done
In April 2018

Answer to Question #4460 in C++ for sanando chakraborty

Question #4460
write a program to print 1,2,-3,4,5,-6,....,nth term.
Expert's answer
#include <iostream>

using namespace std;

void
main(void){
int n = 0;
cout << "Please, enter n = ";

cin >> n;
for(int i = 0; i <= n; ++i)
{
& if ((i
% 3) == 0)
& cout << -i;
& else
& cout
<< i;
& cout << ",";
}
cout << "\nInput
0 and press Enter exit...";
cin >> n;
}

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