Sponsored Ad

Sunday, March 13, 2011

C# Lab Assignment: Program to Print Pascal triangle

This program will help beginners to write their lab assignment and print the Pascal triangle on consol. you can specify limit of Pascal triangle and the program will calculate the Pascal triangle.

C# Lab Assignment: Program to Print Pascal triangle

C# Program for Pascal triangle.

using System;

namespace MyApp
{
    class Pascal_class
    {
        static void Main()
        {
            int nLimit;
            Console.Write("Enter the limit for Pascal Triangle: ");

            nLimit = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < nLimit; i++)
            {
                int c = 1;
                Console.WriteLine(" ");

                for (int j = 0; j <= i; j++)
                {
                    Console.Write(c);
                    Console.Write("");

                    c = c * (i - j) / (j + 1);
                }
                Console.Write(" ");
            }
            Console.Write(" ");
            Console.Read();
        }
    }
}

1 comment:

  1. using System;
    class rev
    {
    public static void Main()
    {
    string name = Console.ReadLine();
    int f = name.Length - 1;
    for (int i = f; i >= 0; i--)
    {
    Console.Write(name[i]);
    }
    Console.ReadLine();
    }
    }

    ReplyDelete

Sponsored Ad

Development Updates