A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a program in C to display the first 10 catalan numbers
Q:

Write a program in C to display the first 10 catalan numbers

0

Write a program in C to display the first 10 catalan numbers


Expected Output :
The first 10 catalan numbers are:
1 1 2 5 14 42 132 429 1430 4862

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

unsigned long int cataLan(unsigned int n)
{
    if (n <= 1) return 1;
    unsigned long int catno = 0;
    for (int i=0; i<n; i++)
        catno += cataLan(i)*cataLan(n-i-1);
    return catno;
}
int main()
{
printf("\n\n Find the first 10 catalan numbers: \n");
printf(" --------------------------------------\n");
printf(" The first 10 catalan numbers are: \n");
    for (int i=0; i<10; i++)
	printf("%lu ",cataLan(i));
	printf("\n");		
    return 0;
} 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now