Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Q.11 Generate the following pattern using code in any
language(c/c++/java) for n no. of rows

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

Answer Posted / balaji ganesh

main()
{
int a[20][20],i,j,n;
clrscr();
a[0][0]=1;
scanf("%d",&n,printf("enter how many rows you want:"));
for(i=0;i<n;i++)
{a[i][0]=1;a[i][i]=1;
for(j=1;j<i;j++)
a[i][j]=a[i-1][j-1]+a[i-1][j];
}
for(i=0;i<n;i++)
{printf("\n\n");
for(j=0;j<=i;j++)
printf("%d ",a[i][j]);
}
getch();
}



Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why c is procedure oriented?

999


How to delete a node from linked list w/o using collectons?

2722


using for loop sum 2 number of any 4 digit number in c language

2258


What is the difference between malloc() and calloc() function in c language?

1029


What is the purpose of void in c?

992


Why do we use pointer to pointer in c?

1021


What is void c?

1013


What does %c mean in c?

1028


What is a constant and types of constants in c?

1069


What is a program flowchart and how does it help in writing a program?

1083


How can I implement a delay, or time a users response, with sub-second resolution?

1033


which is conditional construct a) if statement b) switch statement c) while/for d) goto

1166


When should you use a type cast?

1057


What are different types of variables in c?

1009


Subtract Two Number Without Using Subtraction Operator

781