Do it yourself. NET has been developing for three years. In the past three years, I have worked as a small website in my hometown, and I have been doing repetitive useless work. I came to Shanghai two months ago, and I have joined the company's foreign investment, I bought this C # entry-level Foundation and started reading it again. I have benefited a lot. Now I want to share the topic of every small chapter in this book. As your learning record.
(1) If two integers are stored in the Var1 and Var2 variables, how can we perform a Boolean test to see if one (but not two) is greater than 10?
(2) write an application that contains the logic in exercise (1). the user is required to enter two numbers and display them, but the user is not allowed to accept the case where both numbers are greater than 10, and ask the user to re-enter.
(3) What are the errors in the following code?
Int I;For(i=1;i<=10;i++){ If((i%5) = 0) Continue;Console.wirteline(i);}
The answer is after the flash bullet!
Flashing bullet !~~~~~~~~~~
The answer is as follows:
(1) (Var1> 10) ^ (Var2> 10)
(2)
Bool numbersOK = false; Double var1, var2; Var1 = 0; Var2 = 0; While (! NumberOk) {Console. writeline ("enter a number:"); Var1 = console. readline (); Console. writeline ("enter another number:"); Var2 = console. readline (); If (Var1> 10) ^ (Var2> 10) {Console. wirte ("There may be a number greater than 10, please enter again");} Else {numberOk = false;}) Console. wirteline ("the two numbers you entered are {0}, {1}", var1.tostring (), var2.tostring ());}
(3) The Bool type cannot be determined with a value "= ".
The above resources are from the C # Getting Started classic. Link attached:
Http://t.cn/zjO7kmp