. NET entry-level Test Question 2: Process Control

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.