0
write a program to print the following 1 -4 7 -10 .......-40
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;
}
0
Tyler I thinks he wnats to print the numbers in the same pattern uptill -40.