Code examples

Count parcels after a delivery

Add what came in, then subtract what went out.

Simple example

Start2 + 3 − 1
Result4
Program.cs
using System;

Console.WriteLine(((2 + 3) - 1));
Output
4
Advertisements

Everyday examples

Two boxes hold 6 and 4 parcels. Three parcels go out. How many are left?

Start6 + 4 − 3
Result7
Program.cs
using System;

int first = 6;
int second = 4;
int sent = 3;
Console.WriteLine(((first + second) - sent));
Output
7
Run the example
Terminal
dotnet new console --output Lesson
cp Program.cs Lesson/Program.cs
dotnet run --project Lesson
Official documentation