Sum Of Two Numbers - C# Programming Exercise

This exercise is a great way to practice basic arithmetic operations in C#. In this program, you will learn how to perform an addition operation between two numbers, 12 and 13, and how to display the result on the screen. The program will print the result of the addition on the console.

The instructions for the user are simple:
1. The program will add the numbers 12 and 13.
2. The result of the addition will be displayed on the screen.

This exercise will help you understand how to use the addition operator in C# and how to print the result to the console using Console.WriteLine(). Additionally, it will allow you to start working with arithmetic operators in C#.

 Category

First contact with C# Sharp

 Exercise

Sum Of Two Numbers

 Objective

Write a C# program to print the result of adding 12 and 13 on screen.

 Write Your C# Exercise

using System; // Importing the System namespace to use Console functionalities

// Main class of the program
public class Program
{
    // Main method where the program execution begins
    static void Main()
    {
        // Declaring two integer variables with values 12 and 13
        int num1 = 12;
        int num2 = 13;

        // Calculating the sum of the two numbers
        int sum = num1 + num2;

        // Printing the result of the sum to the screen
        Console.WriteLine("The result of adding 12 and 13 is: " + sum);
    }
}

 Share this C# exercise

 More C# Programming Exercises of First contact with C# Sharp

Explore our set of C# programming exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of C#. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in C#.

  •  Division of two numbers

    This exercise is a great opportunity to practice the division operation in C#. In this program, you will learn how to divide two numbers, in this case, 24 and 5, and ...

  •  Multiple operations and precedences

    This exercise is perfect for learning how to perform complex arithmetic operations in C#. In this program, you will be asked to solve several mathematical operations using d...

  •  Multiply using variables

    This exercise is perfect for learning how to perform a multiplication in C# with numbers entered by the user. In this program, the user will be asked to input two numbers, a...

  •  Use of {0} and comments

    This exercise is great for learning how to interact with the user in C# and perform basic mathematical operations. In this program, the user will be asked to input three num...

  •  Several operations

    This exercise will help you understand how to perform several basic mathematical operations in C#, such as addition, subtraction, multiplication, division, and calculating t...

  •  Multiplication table

    This exercise is perfect for learning how to generate multiplication tables dynamically in C#. In this program, the user enters a number, and the program displays the multip...