C Program to Print 2 15 41 80 132 197 275 366 Numbers Series

Ex: Write a C program to print 2 15 41 80 132 197 275 366 numbers series. How to write a C program to print 2 15 41 80 132 197 275 366 numbers series. C program to print 2 15 41 80 132 197 275 366 numbers series.


Input from user:

Enter the number: 8


Expected output:

2 15 41 80 132 197 275 366


You can explore more number series examples from 👉 series exercises.


  Step by step logic of the given program:


1. Accept input number from user declare variable say no:

2. Run a for loop from 1 to no.

3. Inside that for loop first print value of j and after that use following logic: j=j+(13*i)



  Program to print number series:


#include<stdio.h>

void main()

{

 int i,j=2,no;

 /*Accept input limit of series*/

 printf("Enter the number:\n");

 scanf("%d",&no);

 /*Run a loop from 1 to no*/

 for(i=1;i<=no;i++)

 {

  printf("%d ",j);

  j=j+(13*i);

 }   

}


Above program shows the following output:

C program to print 2 15 41 80 132 197 275 366 numbers series


Feel free to share your thoughts in the comments below...

No comments:

Post a Comment

If you have any doubts, please discuss here...👇