CSharp - Write program to Do Calculations with Variables

Requirements

Use several variables at once.

You are going to store some numbers in two variables.

After that, you will calculate their sum into the third one.

Hint

You can declare a variable and immediately store a value in it.

You can also declare a variable first and store a value in it later.

Demo

using System;

class Program{//from   w w  w .  jav a2  s.  com
    static void Main(string[] args){
        // Values to be summed 
        int firstNumber = 42;
        int secondNumber = 11;

        // Calculating 
        int sum = firstNumber + secondNumber;

        // Output 
        Console.WriteLine("Sum is: " + sum);

        // Declaring all variables at once 
        int thirdNumber, fourthNumber, newSum;

        // Values to be summed 
        thirdNumber = 42;
        fourthNumber = 11;

        // Calculating 
        newSum = thirdNumber + fourthNumber;

        // Output 
        Console.WriteLine("Calculated another way: " + newSum);
    }
}

Result