Computer Small white Learning software development-c# language basis of the cycle of key explanation, exercise

Source: Internet
Author: User

Write code also to read, love the whole stack, more love life. Daily update of original it programming techniques and daily practical videos.

Our goal is: To play with the server Web development, to understand the mobile side, the computer client is a cinch.

This tutorial is a basic tutorial for anyone who is interested in learning software development. Of course, because of the coherence of technology, it is recommended to view in order.

Last lesson: computer small white self-taught software programming-. NET syntax basics of looping statements, pure tips dry

Recently, we are working on writing for the C # language tutorial. Write a series of computer small white learning software development articles, to help more beginners to learn it programming.

Course list: Because the headlines can not be customized catalogue, we are concerned about: "Do the full stack siege Lion" public number. Reply to ". NET directory" and get it. The public number also contains a lot of learning tutorials, waiting for you to come ~

In the previous tutorial, I explained some of the basics. In this lesson, we review some of the previous knowledge points through some exercises.

Let's start with the answers and explanations of the previous tutorial exercises:

1. Calculate the sum of the odd sum of 1-100 and the sum of the even numbers

Because the remainder of even remainder 2 is 0, we can make an odd even number of Garco by judging by If.

Sometimes, you will see the following form:

if (i% 2 = = 0)

Sumodd + = i;

And there is no curly braces to wrap. The usage is that if there is only one statement in the IF, you can use it.

In fact, in general, curly braces are meant to declare the scope.

2. Calculation 1+1/2+......+1/100

When we run, however, we find the result:

Obviously, this is wrong!!

But our logic is not wrong ah?? What's going on. Here's the point:

Improvement Method:

3, enter a three-digit number, output their single-digit, 10-digit, the hundred number.

The hundred number calculation, gave the analytic, the single digit and 10 people to look carefully to understand. Leave a question.

Think: However, if you want to randomly calculate a value. Separate the number of each of their digits. How does it work?

4, Beg 1*2*3*..........*n. Cycle

5, 1+2+3+4+6+7+8+9+11++.+99= (not add 5 multiples)

6, to satisfy the 1+2+3+...+n<500 the largest n, and to seek its and, write program implementation.

This article by doing full stack Siege Lion original debut, if reproduced please declare the source.

WX platform: Make full stack siege Lion, submit Wx:aiquanzhan

This article is original to the headline number author. Without authorization, may not be reproduced.

Computer Small white Learning software development-c# language basis of the cycle of key explanation, exercise

Related Article

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.