Computer Science, asked by snehalnanekar1999, 10 months ago

Write a cpp program to generate the following series 0,2,8,14,...,34.

Answers

Answered by Yamini1999
0

Answer:

include<iostream>

using namespace std;

int main()

{

int n,x;

 cin>>n;

 for (int i = 1; i <= n; i++)

   {

   x=i*i;

   if (x%2 == 0)

   cout<< x - 2<<" ";

 else

   cout<< x - 1<<" ";

   }  

}

Answered by akumawat1402
1

Answer:

#include<iostream>

using namespace std;

int main()

{  

 int n,x=1,i,sq;

 cin>>n;

   for(i=1;i<=n;i++){

   if(i%2==0)

   {

     sq=(x*x)-2;

     cout<<sq<<" ";

     x++;

   }

   else

   {

     sq=(x*x)-1;

     cout<<sq<<" ";

     x++;

   }

 }

}

Explanation:

Similar questions