4 Réponses
+ 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.
+ 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!
0
not working
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.