I have a project about making pascal triangle using recursive function.
This is the example output:

1 1
1 2 1
1 3 3 1
1 4 6 4 1

Hint:(x+y) n=>exponent.
*Give me an idea about this project. Thanks!

Recommended Answers

All 5 Replies

You need to show us some efford before we can help you xD

Do you know how to create a pascal triangle without recursive?

If so then doing it recursive won't be that far off. Give it a go and see
what happens.

/* Program to print the Pascal's triangle recursively */


int pascal(int,int);
void space(int,int);

	int num,i,j;
	printf("\nEnter the no. of rows required: ");

int pascal(int row,int column)
		return 0;
	else if(row==1&&column==1)
		return 1;
	else if(column>row)
		return 0;
		return (pascal(row-1,column-1)+pascal(row-1,column));

void space(int num,int mul)
	int i;
		printf(" ");
commented: He only wants the idea.Dont give code directly! +0

This code will do the job

#include <iostream>

long calc(int n, int r) {
     if ((n == 0) || (r == 0) || (n == r)) return 1;
     else return (calc(n-1,r-1) + calc(n-1,r));
} // This is the recursive function

int main() {
    printf("Enter a number = ");
    int num;
    scanf("%i", &num);
    for (int i = 0; i<=num; i++) {
        for (int j = num; j > i; j--) printf("   ");
        for (int k = 0; k <= i; k++) printf("%6d", calc(i,k));
    } // End of for loop
    return 0;
commented: Give a chance to him to try something. +0
commented: bump -3

@shellexecutor: Don't bump 2 year old threads (the OP probably doesn't care anymore), and don't provide fully working code, especially for such a classic homework problem (pascal triangle) and when the OP didn't show much effort of his own.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.