Fix please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
27th Jun 2017, 5:58 PM
malti thakur
malti thakur - avatar
4 Answers
+ 1
static void Main(string[] args) { int n1; int n2; Console.WriteLine("Write First number"); n1=Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Write Second Number"); n2=Convert.ToInt32(Console.ReadLine()); Console.WriteLine(n1+"Divided by"+n2+"is"+n1/n2); } ^That's all I did to fix it. ReadLine() didn't have Console. in front of it. Works fine on my end. What are you putting for your input when it prompts you? You don't regulate the input, so there are many ways to create an error with your input.
27th Jun 2017, 6:06 PM
AgentSmith
+ 1
Change: n1=Convert.ToInt32(ReadLine()); To: n1=Convert.ToInt32(Console.ReadLine()); ;) You forgot the class name. I know you're just practicing, but when dealing with user input, you'll want to make sure you check it prior to submission to prevent errors. For example, don't let them divide by zero, make sure inputs isn't blank, make sure they didn't input invalid type (if so, have them enter again), etc... You get the point. Anyways, best of luck to you!
27th Jun 2017, 6:06 PM
AgentSmith
0
not working
27th Jun 2017, 6:02 PM
malti thakur
malti thakur - avatar
0
If it's not working for you, what error are you generating Malti? It works fine on my end once I added the class name in front of ReadLine method.
27th Jun 2017, 6:07 PM
AgentSmith