C# - How To Create A Trapezoid Star Program In C#

C# - How To Create A Program To Print Trapezoid Star Program In C#

                                                                                                                                                     

In This C# Code We Will See How To Make A Program To Print A Trapezoid Using For Loop In C# Programming Language.

Source Code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
 
           int k = 10;//number of spaces
           int d = 20;//number of stars

       
         //loop for 10 lines
        for(int i = 0; i < 10; i++){
            
             for(int l = k; l > 1; l--){
                Console.Write("  ");//two spaces
            }        
   
            //loop for d stars
            for(int j = 0; j < d; j++){
                Console.Write("*");
            }
 
            Console.WriteLine();
             
             k--;//discriminate the number of spaces
             d = d+4;//increment the number of stars

        }
        
            Console.ReadLine();
        }
    }
}
//////////OUTPUT:

Trapezoid Star In C#
Trapezoid In C#




Share this

Related Posts

Previous
Next Post »