Login
Register
Tutorials
Forum
Career Development
Resources
Reviews
Jobs
Interview
Communities
Projects
Training
Silverlight Games
|
Bookmarks
|
New Members FAQ
|
Mentor
|
Code Converter
|
IT Companies
|
Peer Appraisal
|
Members
|
Revenue Sharing
|
Computer Jokes
|
New Posts
|
Social
|
Talk to Webmaster Tony John
Online Members
Pritom Nandy
More...
Forums
»
.NET
»
.NET
»
Pascal triangle progaam in C# console application
Posted Date:
25 Sep 2008
Posted By::
Kumaresh
Member Level:
Gold
Member Rank:
598
Points
: 1
Responses:
1
How to code the "Pascal triangle" progaam in C# console application.
Formula:Pij = Pi-1, j-1 + Pi-1, j
output: 1
1 1
1 2 1
1 3 3 1
Tweet
Responses
#300595 Author:
Giribabu
Member Level:
Gold
Member Rank:
348
Date: 26/Sep/2008 Rating:
Points
: 5
Generating Pascal Triangle
using System;
class pascalTriangle
{
public static void Main()
{
int binom=1,q=0,r,x;
Console.WriteLine("Enter the number of rows");
string s=Console.ReadLine();
int p =Int32.Parse(s);
Console.WriteLine(p);
Console.WriteLine("The Pascal Triangle");
while(q<p)
{
for(r=40-(3*q);r>0;--r)
Console.Write(" ");
for(x=0;x<=q;++x)
{
if((x==0)||(q==0))
binom=1;
else
binom=(binom*(q-x+1))/x;
Console.Write(binom);
}
Console.Write("\n ");
++q;
}
}
}
--Giri
http://giribabu.wordpress.com
Post Reply
This thread is locked for new responses. Please post your comments and questions as a
separate thread
.
If required, refer to the URL of this page in your
new post
.
Tweet
Next :
Negative fibonacci series and fibonacci series in C#.net
Previous :
Add integer values to an array + console application using c#
Return to Discussion Forum
Post New Message
Category:
Related Messages
Is there any expert to solve this?
what is difference between String and string(data type) in c#?
what is a resource file...
Horizontal Scroll Bar for a listview control
sql querry
Active Members
Today
Jivani
(23)
naveensanagase...
(21)
Asheej T K
(20)
Last 7 Days
baskar
(303)
Ultimaterengan
(267)
Rakesh Chaubey
(184)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds