C Language Learning Four

Source: Internet
Author: User

Today review the C language type conversion and branching structure, C is a strong data type, and his grammar compiler is not as strict as other languages later, so we must pay attention to our own data type when using it. Type conversions are divided into: Forced type conversions and automatic conversions. The so-called forced catch is the process of artificially adding the data type that you want to convert before the result, for example: int a= (int) (1.000), which is 1.00 will be cast to 1. The so-called automatic conversion is the automatic conversion of the program. For example: "=" the so-called assignment number is a potential automatic conversion. For example: int a=1.0; When we use printf () to output it, the result is 1. Because a has converted 1.0 to 1 when it is given a value. The principle that auto-conversions follow is a small range of data type conversions to a large range of data types.

Two: Branch structure: Branch structure includes single branch and multi-branch, single branch is if and Else branch is switch;

Three: Circular structure: The loop structure can be expressed in three ways: for (), while, Do-while ()

For syntax:

for (int i=0;i<10;i++) {

}

while (judging condition) {

}-----------------First judge and then execute the

do{

}--------------Features: First execute once and then judge

while (judging condition)

C Language Learning Four

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.