w3resource

C#: Print the sum of two numbers


Sum of Two Numbers

Write a C# Sharp program to print the sum of two numbers.

In mathematics, summation (capital Greek sigma symbol: ∑) is the addition of a sequence of numbers; the result is their sum or total. The numbers to be summed may be integers, rational numbers, real numbers, or complex numbers.

C# sharp Exercises: Print the sum of two numbers

Sample Solution:

C# Sharp Code:

// This is the beginning of the Exercise2 class
public class Exercise2
{
    // This is the main method where the program execution starts
    public static void Main()
    {
        // This line performs addition of 15 and 17 and outputs the result to the console
        System.Console.WriteLine(15 + 17);
    }
}

Sample Output:

32 

Flowchart:

Flowchart: C# Sharp Exercises - Print the sum of two numbers

For more Practice: Solve these Related Problems:

  • Write a C# program that takes two floating-point numbers, rounds them, and then calculates their sum.
  • Write a C# program that reads two hexadecimal numbers from input and prints their sum in decimal form.
  • Write a C# program to add two user-entered values but swap them using XOR logic before adding.
  • Write a C# program that calculates the sum of two randomly generated integers between 100 and 999 and checks if the result is even.

Go to:


PREV : Print Hello and Name.
NEXT : Divide Two Numbers.

C# Sharp Code Editor:



What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.