C++ Program to Print Series 1 -4 7 -10 . . . . -40

Here you will get a C++ program to print series 1 -4 7 -10 . . . . -40.

#include<iostream>

using namespace std;

int main()
{
	int i,a=-1,b;
	for(i=1;i<=40;i+=3)
	{
		a*=-1;
		b=i;
		b*=a;
		cout<<b<<" ";
	}
	
	return 0;
}

Output:

1 -4 7 -10 13 -16 19 -22 25 -28 31 -34 37 -40

For any queries related to the above code ask in the comment section below.

8 thoughts on “C++ Program to Print Series 1 -4 7 -10 . . . . -40”

  1. hussein M.Rada

    a program that inputs series of integers and passes them one at a time to a function even which uses the modulus operator (%) to determine if an integer is even. The function should take an integer argument and return 1 if the integer is even and 0 otherwise.

Leave a Comment

Your email address will not be published. Required fields are marked *