-1 0 3 8 15 24 (Number Series)

#include<iostream.h>

int main()
{
 int n=-1;
 int d=1; // diff
 int limit;
 
 cout<<"Enter limit upto which series is to be generated : ";
 cin>>limit;
 
 do 
 {
   cout<<n<<" ";
   n = n + d;
   d = d + 2;
 }while(n<=limit);

}
OUTPUT:-
Enter limit upto which series is to be generated : 25
-1 0 3 8 15 24

Related Post

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.