In this article we will learn create Pascal’s Triangle in vb.net.
Create Pascal’s Triangle in vb.net
The rows of Pascal’s triangle are conventionally enumerated starting with row n=0 at the top (the 0th row). The entries in each row are numbered from the left beginning with k=0 and are usually staggered relative to the numbers in the adjacent rows.
Code for create Pascal’s Triangle in vb.net
Imports System Module Program Sub Main(args As String()) Dim rowNumber, blank, i, j As Integer, c As Integer = 1 Console.Write(vbLf & vbLf) Console.Write("Input number of rows for Display the Pascal's triangle: ") Console.Write(vbLf & vbLf) rowNumber = Convert.ToInt32(Console.ReadLine()) For i = 0 To rowNumber - 1 For blank = 1 To rowNumber - i Console.Write(" ") Next For j = 0 To i If j = 0 OrElse i = 0 Then c = 1 Else c = c * (i - j + 1) / j End If Console.Write("{0} ", c) Next Console.Write(vbLf) Next Console.ReadLine() End Sub End Module
Advertisement
Output for create Pascal’s Triangle in vb.net
Advertisement