﻿ C Program: Print the first 20 numbers of the Pell series - w3resource

C Exercises: Print the first 20 numbers of the Pell series

C Numbers: Exercise-35 with Solution

Write a program in C to print the first 20 numbers of the Pell series.

Sample Solution:

C Code:

``````# include <stdio.h>
# include <stdlib.h>

int main()
{
int n,a=1,b=0,c;
printf("\n\n Find the first 20 numbers of the Pell series: \n");
printf(" --------------------------------------------------\n");
printf(" The first 20 numbers of Pell series are: \n");
c=0;
printf(" %d ",c);
for(n=1; n<20; n++)
{
c= a + 2*b;
printf("%d ",c);
a = b;
b = c;
}
printf("\n");
}
```
```

Sample Output:

```The first 20 numbers of Pell series are:
0 1 2 5 12 29 70 169 408 985 2378 5741 13860 33461 80782 195025 470832 1136689 2744210 6625109
```

Pictorial Presentation:

Flowchart:

C Programming Code Editor:

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿

C Programming: Tips of the Day

Why do C and C++ compilers allow array lengths in function signatures when they're never enforced?

It is a quirk of the syntax for passing arrays to functions.

Actually it is not possible to pass an array in C. If you write syntax that looks like it should pass the array, what actually happens is that a pointer to the first element of the array is passed instead.

Since the pointer does not include any length information, the contents of your [] in the function formal parameter list are actually ignored.

Ref : https://bit.ly/3fhlvdH