C Language Basics Lesson---------basic data types, constants, variables

Source: Internet
Author: User

int main () {

Single-line comment: Comment Line

/*

Multiline Comment: Within this interval, it is a multi-line comment that can be wrapped.

*/

#pragma mark---basic data type----

/*

Char character type contains: ' A~z ' a~z ' 0~9 ' and so on

int integral type contains: number 1234567890, etc.

Float Float type contains: Number 1.2 2.5 and so on

Short shorter integer contains: number 123456789, etc.

Long length shaping includes: number 123456789, etc.

Double-progress floating-point type contains: Number 1.1 2.2 3.3 and so on

*/

/*

Binary: Rounding mechanism

decimal-to-n-binary: Even removing the rewind method

N-Decimal: Weighted summation method

*/

#pragma mark----constants, variables-------

Constants: The amount of values that can not be changed during a program run;

integer constant; 10 12 15 and so on.

Floating-point constants, 5.5 5.4, etc.

Character type constant: ' A ' a ' 5 '

Variables: The amount of values that can change during a program's run

/*

Define variables: Consists of three parts: type modifier variable name = initial value

*/

Example: Define an integer variable named age with an initial value of 20;

int age= 20;

Define a character variable named name and the initial value is w;

Char name = ' W ';

Defines a single-precision floating-point variable named cost with an initial value of 1.2;

float cost = 1.2;

Define a short integer variable named a with an initial value of 10;

Short a=10;

Defines a double-precision floating-point variable with a variable named T and an initial value of 22.02;

Double t=22.02;

Defines a long integer variable named B with an initial value of 1234;

Long b= 1234;

Age = 29;

name = ' h ';

Cost = 2.2;

A = 3;

t = 2.3;

b = 123;

1. Variable names consist of numbers, letters, underscores, and cannot begin with a number;

int 3a=0;

int a3_=0;

int _3a=0;

2. Cannot have the same name as the system reserved word

int int=0;

int return=0;

3. Cannot use duplicate variable names

int f=0;

int f=5;

4. See the name (Code specification)

FLOAT score = 98.5;

int age = 9;

int myAge = 29;

int/**/a=0;

in/**/t

C Language Basics Lesson---------basic data types, constants, variables

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.