0

write a program to print the following 1 -4 7 -10 .......-40

21st Sep 2016, 7:20 PM
Prakhar
Prakhar - avatar
2 Answers
+ 2
#include <iostream> using namespace std; int main() { int a=1, counter=1; while(a!=(43)) { cout << a << endl; if ((counter%2)!=0) a = (a+3)*(-1); else a = a*(-1) + 3; ++counter; } return 0; }
21st Sep 2016, 10:24 PM
Mohammed Maaz
Mohammed Maaz - avatar
0
Tyler I thinks he wnats to print the numbers in the same pattern uptill -40.
22nd Sep 2016, 4:55 PM
Mohammed Maaz
Mohammed Maaz - avatar