any one can tell me how to do pascal triangle program

commented: For being plain lazy and arrogant -1

program needed

Hi
please find the code below. i have tested the program in linux. it might give some minor error in turbo-c but i hope u can correct those.

#include<stdio.h>

void drawPascalTriangle(int rows);
void getRow(int *prevRow, int prevRowSize, int *row);
void copyRow(int *prevRow, int *row, int rowSize);
void dispRow(int *row, int rowSize, int rows);

int main()
{
	int rows;
	printf("Enter no. of rows:");
	scanf("%d", &rows);
	
	drawPascalTriangle(rows);
	return 0;
}

void drawPascalTriangle(int rows)
{
	int prevRow[50];
	int row[50];
	int prevRowSize = 0;
	int rowSize = 0;
	int i;
	for(i=0;i<rows;i++)
	{
		getRow(prevRow, i, row);
		dispRow(row, i+1, rows);
		printf("\n");
		copyRow(prevRow, row, i+1);
	}
}

void getRow(int *prevRow, int prevRowSize, int *row)
{
	int i;
	for(i=0;i<prevRowSize;i++)
	{
		if(i==0)
		{
			*row = *prevRow;
		}
		else
		{
			*row = *(prevRow) + *(prevRow-1);
		}
		row++;
		prevRow++;
	}
	*row = 1;
}
void copyRow(int *prevRow, int *row, int rowSize)
{
	int i;
	for(i=0;i<rowSize;i++)
	{
		*prevRow = *row;
		prevRow++;
		row++;
	}
}
void dispRow(int *row, int rowSize, int rows)
{
	int i;
	for(i=0;i<rows-rowSize;i++)
		printf("    ");
	for(i=0;i<rowSize;i++)
	{
		printf("%4d    ", *row);
		row++;
	}
}

@dkalita,

We do not freely give out code on these forums unless the poster shows some effort. Since you are a "newbie", you need to read this:

http://www.daniweb.com/forums/announcement118-2.html

commented: Well said - dunno what crazy shit the other person was smoking though - must be good whatever it is ;) +36

In c program to create a chess board ?

commented: keep smoking the weed -7
commented: For being lazy. Go somewhere else if you're not prepared to put in any effort! -1

Stop hijacking threads. Start a new thread and learn how to read. Did you not read my previous post?

SHOW SOME EFFORT!! Your request and that of the OP just show how bloody well lazy the both of you are.

Sheesh.

thanks for giving program but i need only the concept of that program not the whole program.
give me concept of tsr and its uses

commented: Try a search engine then -7

@dkalita,

We do not freely give out code on these forums unless the poster shows some effort. Since you are a "newbie", you need to read this:

http://www.daniweb.com/forums/announcement118-2.html

hey, sorry for that. Actually i am new to this forum and dont know the rules. I will keep this in mind from now.