+ 1
What is wrong on my code? C# Add two number
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int x ; int y ; x= Console.Read(); y= Console.Read(); Console.WriteLine(x-y); } } }
3 Answers
+ 3
Sayem chy
You wrote in question Add two numbers but you are doing subtraction. Why?
+ means addition
- means subtraction
* multiplication
/ division
+ 2
When you read from console, strings will be returned. You declared x and y as int, hence you need to cast the input to integer before assigning it to x and y.
Also "add" means +, not â.