C program to Calculate 2 15 41 80 132 197 275 366 470 587 series

In c language you can print any number series. Here i will show you how to print number series in c language with explanation. In case of print number series you need to focus on common difference between two numbers..

C program to Calculate 2 15 41 80 132 197 275 366 470 587 series




#include<stdio.h>
int main()
{
    int a=2,i,n=10;
    for(i=1;i<=n;i++)
    {
        printf("%d ",a);
        a+=13*i;
    }
    return 0;
}



Output:


2 15 41 80 132 197 275 366 470 587




#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,i,n;
    printf("Enter a value:");
    scanf("%d",&a);
    printf("Enter size of Series:");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        printf("%d ",a);
        a+=13*i;
    }
    return 0;
}




Output:

Enter a value:5
Enter size of Series:20
5 18 44 83 135 200 278 369 473 590 720 863 1019 1188 1370 1565 1773 1994 2228 2475
Process returned 0 (0x0) execution time : 4.401 s




Instagram