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 =...
Tag - C# For Loop Examples
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...
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) {...
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...
Find Average of Even and Odd of N Numbers Entered by User
In this example, I’ll show How to Calculate average of even & odd of N numbers entered by user. Firstly, we will ask the user how many numbers to enter. Source Code: C# static void Main(string[] args) { int...
Calculate Average of First n Even Natural Numbers in C#
In this example, I’ll show how to find average of First N natural numbers in C#. C# Code: C# static void Main(string[] args) { int n, count = 0, sum=0,average; Console.Write("n : "); n = Convert.ToInt32(Console.ReadLine());...
C# Loop Examples
Loops are structures that control repeated executions of a block of statements. • C# provides a powerful control structure called a loop, which controls how many times an operation or a sequence of operation is performed in...
C# Program to Calculate the Power of a Number Without Using Math.Pow
This C# program computing an of the number that given two integers base and exponent by user. Create a program that takes two integers base and exponents and compute the exponents without using Math.Pow() Create Custom Pow Method...