int num1 = 10, num2 = 5;
num1 - = num2 ;//num1 = num1 - num2
Console.WriteLine("Addition is {0}",num1);
How come it shows num1 value = 10 as output
Plz help...
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 17, 2013, 1:28 AM EDT
in your code:
step 1
using System;
class Class3
{
static void Main()
{
int num1 = 10, num2 = 5;// initialise the value of num1 to 10 and num2 to 5
num1 -=num2;// here it will substract num1 with num2 and assign it to num1. the new value is 5
Console.WriteLine("Addition is {0}",num1); // it will print the num1 value.
Console.ReadLine();
}
}
Output: 5