 C# For Loop Examples – Programming, Pseudocode Example, C# Programming Example

# Tag - C# For Loop Examples

## Create Matrix(5 x 5) of Type Integer Holding Random Values in C#

In this example, i’ll show you How to create a matrix of random integers in C#. C# Code: C# static void Main(string[] args) { Random rnd = new Random(); const int MATRIX_ROWS = 5; const int MATRIX_COLUMNS = 5; double[,]...

## Creating a 3×3 Matrix With User Input Numbers in C#

In this example, I will create a program that allows the user to enter numbers by creating a 3×3 matrix in the C # programming language. C# Code: C# static void Main(string[] args) { const int MATRIX_ROWS = 3; const int...

## Input an integer (n) and computes the value of a+aa+aaa in C#

Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a in C#. Write a C# program that accepts an integer (n) and computes the value of n+nn+nnn. C# Code: C# class Program { static void...

## Square pyramidal number (Sum of squares) of first n natural numbers in C#

In mathematics, a pyramid number, or square pyramidal number, is a figurate number that represents the number of stacked spheres in a pyramid with a square base. Square pyramidal numbers also solve the problem of counting the...

## Display Even Numbers Between 1 to N Using For Loop in C#

Write a C# Console Application program to print even numbers between 1 to N using for loop. C# Code: C# static void Main(string[] args) { Console.Write("Number : "); int number = Convert.ToInt32(Console.ReadLine()); for (int i =...

## Display Odd Numbers Between 1 to N Using For Loop in C#

Write a C# Console Application program to print odd numbers between 1 to N using for loop. C# Code: C# static void Main(string[] args) { Console.Write("Number : "); int number = Convert.ToInt32(Console.ReadLine()); for (int i =...

## Display Odd Numbers Between 1 to 100 Using For Loop in C#

Write a C# Console Application program to print odd numbers between 1 to 100 using for loop.   C# Code: C# static void Main(string[] args) { for (int i = 1; i <= 100; i++) { if(i%2==1) { Console.WriteLine(i); } } Console...

## Display Even Numbers Between 1 to 100 Using For Loop in C#

Write a C# Console Application program to print even numbers between 1 to 100 using for loop.   C# Code: C# static void Main(string[] args) { for (int i = 1; i <= 100; i++) { if(i%2==0) { Console.WriteLine(i); } } Console...

For Loop

## C# for loop & Examples

C# for loop One usually uses a for loop when it is known how often certain instructions need to be executed. The general syntax of the for-loop construct looks like this: C# for ( expression1; expression2 ; expression3) {...

C# Console

## Program to check whether a number is prime or not in C# Console

Example to check whether an integer (entered by the user) is a prime number or not using for loop and if…else statement. A positive integer which is only divisible by 1 and itself is known as prime number. For example: 17...