Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
****
****
****
****
how to print * in c# program,

my code:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the number");
            int n = Convert.ToInt32(Console.ReadLine());
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    Console.Write("*");
                }
                Console.WriteLine("");
                Console.ReadLine();
            }
        }

    }
}



soution : enter the number 5
*****


how can i print ****
****
****
****
Posted
Updated 14-Nov-11 19:14pm
v2

C#
static void Main(string[] args)
        {
            Console.WriteLine("Enter the number");
            int n = Convert.ToInt32(Console.ReadLine());
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j < 4; j++)
                    Console.Write("*");

                Console.WriteLine("");
                Console.ReadLine();
            }
        }
 
Share this answer
 
i got this soution

// console.Readline(); line mention is out side for loop//
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900