
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
How to print a diamond using nested loop using C#?
With C#, you can easily display the following diamond shape.
$ $$$ $$$$$ $$$$$$$ $$$$$$$$$ $$$$$$$ $$$$$ $$$ $
To display a diamond shape, you need to focus on the following points −
Number of rows Dollar sign to be displayed Empty spaces
Considering the above you can easily create the diamond shape as shown in the below code −
Example
using System; namespace Program { public class Demo { public static void Main(String[] args) { int i, j, r, d, e; // rows = 5 r = 5; // display dollar sign d = 1; // empty space e = r - 1; for (i = 1; i < r * 2; i++) { // display empty space for (j = 1; j <= e; j++) Console.Write(" "); for (j = 1; j < d * 2; j++) Console.Write("$"); Console.WriteLine(); if (i < r) { e--; d++; } else { e++; d--; } } } } }
Output
$ $$$ $$$$$ $$$$$$$ $$$$$$$$$ $$$$$$$ $$$$$ $$$ $
- Related Articles
- C program to print four powers of numbers 1 to 9 using nested for loop
- How to print the stars in Diamond pattern using C language?
- How to print a name multiple times without loop statement using C language?
- Print a pattern without using any loop in C++
- C program to print number series without using any loop
- Java Program to print Number series without using any loop
- C program to print multiplication table by using for Loop
- Program to print numbers from 1 to 100 without using loop
- How to print a one-month calendar of user choice using for loop in C?
- A nested loop puzzle?
- C program to print name inside heart pattern using for loop.
- How will you print numbers from 1 to 100 without using loop in C?
- Java program to print the fibonacci series of a given number using while loop
- Print Number series without using any loop in Python Program
- Python Program for Print Number series without using any loop

Advertisements