C basics _ note _ 1, note _ 1

Source: Internet
Author: User

C basics _ note _ 1, note _ 1

Define Variables

Int I;

Yes.

Int I, num;

Assign value. c must first define the variable and then assign value.

Num = 0;

Loop

For (I = 1; I <= 0; I ++)

{

Printf ("% d \ n", I); # It is similar to python usage.

}

Loop while

While (I <= 10)

{

Printf ("% d \ n", I );

I ++;

}

You can also write it like this.

While (1)

{

If (I> 10)

{

Break;

}

Printf ("% d \ n", I );

I ++;

}

The following is a complete example.

# Include <stdio. h>

Int main ()

{

Int I, num;

Num = 0;

While (1)

{

If (I> 10)

{

Break;

}

Sum = sum + I;

I ++;

}

Printf ("% d \ n", sum );

}

# The include header file is used to call the library, but I don't think it is necessary to remember it, just like the python import. Check the record when using it or Baidu

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.