Assignment and Compound Assignment in C#
📖 Scenario: You are helping a small shop owner keep track of the number of items in stock. You will use simple assignment and compound assignment to update the stock count as items are added or sold.
🎯 Goal: Build a small C# program that creates a stock count variable, updates it using assignment and compound assignment operators, and then prints the final stock count.
📋 What You'll Learn
Create an integer variable called
stockCount with an initial value of 50.Create an integer variable called
newShipment with a value of 20.Use the assignment operator
= to set stockCount to 50.Use the compound assignment operator
+= to add newShipment to stockCount.Use the compound assignment operator
-= to subtract 15 from stockCount.Print the final value of
stockCount.💡 Why This Matters
🌍 Real World
Keeping track of stock counts is important for shops to know how many items they have available.
💼 Career
Understanding assignment and compound assignment is a basic skill for programming jobs that involve data updates and calculations.
Progress0 / 4 steps