;

# C# Program to Print the Sum of Even and Odd Numbers.

###### Tutorialsrack 11/08/2019 C# Programs

In this C# program, we will learn how to write a program to Print the Sum of Even and Odd Numbers.

Here is the code of the program to Print the Sum of Even and Odd Numbers:

##### Code - C# Program To Print the Sum of Even and Odd Numbers.
``````using System;

namespace TutorialsrackPrograms
{
class Program
{
//C# Program to Print the Sum of Even and Odd Numbers.
static void Main(string[] args)
{
int limit, totaleven = 0, totalodd = 0;
Console.Write("Enter The Range You Want to Sum of Even and Odd Numbers: ");
Console.WriteLine("-------------------------------------------------------------");
Console.Write("Even Numbers:");
Console.WriteLine("\t Odd Numbers:");
for (int num = 0; num < limit; num++)
{
if (num % 2 == 0)
{
Console.Write(" {0}", num);
totaleven = totaleven + num;
}
else
{
Console.WriteLine(" \t\t\t {0}", num);
totalodd = totalodd + num;
}
}
Console.WriteLine(" \n Sum of All Even Numbers are : {0} \n Sum of All Odd Numbers are : {1}", totaleven, totalodd);
}
}
}``````
##### Output

Enter The Range You Want to Sum of Even and Odd Numbers: 20
-------------------------------------------------------------
Even Numbers:      Odd Numbers:
0                                          1
2                                          3
4                                          5
6                                          7
8                                          9
10                                      11
12                                      13
14                                      15
16                                      17
18                                      19

Sum of All Even Numbers are: 90
Sum of All Odd Numbers are: 100