
- 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 generate the first 100 even Numbers using C#?
To generate first 100 even numbers, set a for loop from 1 to 100.
for(val = 1; val <= 100; val++) {}
Under the loop, set the condition for even numbers i.e. if the mod 2 of a number is 0, then it is an even number.
for(val = 1; val <= 100; val++) { if(val%2 == 0) { Console.WriteLine(val); } }
The following is the complete example.
Example
using System; class Program { static void Main() { int val; for(val = 1; val <= 100; val++) { if(val%2 == 0) { Console.WriteLine(val); } } } }
Output
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100
- Related Articles
- How to generate the first 100 Odd Numbers using C#?
- C# Program to Generate Random Even Numbers Using LINQ Parallel Query
- How to print the first ten Fibonacci numbers using C#?
- How to generate prime numbers using Python?
- How to generate pyramid of numbers using Python?
- Sum of squares of the first n even numbers in C Program
- Program to generate first n lexicographic numbers in python
- Average of first n even natural numbers?
- Swift Program to calculate the sum of first N even numbers
- Find the sum of first and even natural numbers.
- Find the mean of first 10 even natural numbers.
- C++ Program to Generate Random Numbers Using Middle Square Method
- C++ Program to Generate Random Numbers Using Probability Distribution Function
- C# Program to Generate Odd Numbers in Parallel using LINQ
- Generate random numbers using C++11 random library

Advertisements