A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C# Sharp program to display by Pascal's triangle
Q:

Write a C# Sharp program to display by Pascal's triangle

0

Write a C# Sharp program to display by Pascal's triangle

Sample Output:

Display the Pascal's triangle:                                                                                          
--------------------------------                                                                                                         
Input number of rows: 8                                                                                                         
                1                                                                                                         
              1   1                                                                                                         
            1   2   1                                                                                                
          1   3   3   1                                                                                                         
        1   4   6   4   1                                                                                                         
      1   5   10   10   5   1                                                                                                         
    1   6   15   20   15   6   1                                                                                                         
  1   7   21   35   35   21   7   1
  

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;  
public class Exercise33 
{  
    public static void Main()
{
    int no_row,c=1,blk,i,j;
	
	Console.Write("\n\n");
    Console.Write("Display the Pascal's triangle:\n");
    Console.Write("--------------------------------");
    Console.Write("\n\n");  	
	
    Console.Write("Input number of rows: ");
    no_row = Convert.ToInt32(Console.ReadLine());	
    for(i=0;i<no_row;i++)
    {
        for(blk=1;blk<=no_row-i;blk++)
        Console.Write("  ");
        for(j=0;j<=i;j++)
        {
            if (j==0||i==0)
                c=1;
            else
               c=c*(i-j+1)/j;
            Console.Write("{0}   ",c);
        }
        Console.Write("\n");
    }
  }	
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now