在撰写本文时,我大约花了 2 个小时学习 C#(以及一般编程),我正在尝试编写一个简单的程序来帮助我的儿子学习将两位数相加。我拥有的是
//Creating needed variables
using System.Data.Common;
int num1, num2, answer, numCorrect, numIncorrect, question;
String userAnswer;
Random random = new Random();
numCorrect = 0;
numIncorrect = 0;
//Looping the question for 10 rounds
for (question = 0; question < 11; question++)
{
//Defining Numbers
;
num1 = random.Next(1, 100);
num2 = random.Next(1, 100);
//The Problem
Console.WriteLine(num1 + "+" + num2 + "= ?");
userAnswer = Console.ReadLine();
answer = Convert.ToInt32(userAnswer);
//Logic that will provide the ansewer.
if (answer == …Run Code Online (Sandbox Code Playgroud)