C-Language Summary----data type + operator + expression

Source: Internet
Author: User
Tags arithmetic arithmetic operators naming convention

C-Language Summary----data type + operator + expression

===========================================================================

First part data type

===========================================================================

C language requires data to have a clear data type 650) this.width=650 before processing the data; "src=" Http://img.baidu.com/hi/face/i_f09.gif "alt=" I_f09.gif "/> 650) this.width=650; "src=" Http://img.baidu.com/hi/face/i_f09.gif "alt=" I_f09.gif "/>650" this.width=650; "src=" Http://img.baidu.com/hi/face/i_f04.gif "alt=" I_f04.gif "/>650" this.width=650; "src=" http://img.baidu.com/hi/ Jx2/j_0016.gif "alt=" J_0016.gif "/>650" this.width=650; "src=" Http://img.baidu.com/hi/bobo/B_0013.gif "alt=" b_ 0013.gif "/>. In the C language, data types can be categorized into basic data types, representations, occupy storage types, pointer types, and empty types.

One, constant

The value of a constant does not change while the program is running, it is a constant. Constants are divided into direct constants and symbolic constants.

1. Direct constant

1) Shaping constants;

2) character constants;

3) the real type constant;

4) string constants;

2. Symbolic constants

Symbolic constants replace constants with identifiers. Defining constants is required to execute using a pre-processing command, # define. The definition format is:

#define PI 3.14

Second, the variable

Unlike constants, variables can be changed in a program run. There are two elements in a variable: variable name, variable value. Where the variable name is the name of the variable, the name needs to follow the identifier naming convention. The value of the variable is the value stored in the memory of the variable, and the variable name is used to refer to it during the program's run.

1. Variable definition

1) Define the format

For example: float a,b,c

2) Variable initialization format

For example:float a=1,b=3,c,d


Three, integral type constant

1.

Four, the integral type variable


Five, the real type constant


Six, character-type constants


Seven, character type variable


Eight, string constants


Ix. output of data

1. Data output Syntax format

the function name (parameter 1, parameter 2, ...). Parameter n);

2. printf formatted output function

1) Direct output information when only one parameter is supplied

For example:printf ("Hello world!");

2) when outputting multiple parameters, you need to add the format control character

For example:printf ("Hello world!%d", a);

3. Format Control character

%d displays signed integer data, such as Int,short type data;

%u shows unsigned integer data, such as unsigned int, unsigned short data;

%f display of real data, such as float type data;

%c Displays character data, such as char type data;

%s displays string data;



=========================================================================

Second part operator

=========================================================================


One, assignment operators

An assignment symbol = An assignment operator that assigns the value of an expression to a variable, both by writing a specific value to the memory unit of the variable.

For example: int x;

x=2;

Second, arithmetic operators

There are 5 arithmetic operators, including: plus (+), minus (-), multiply (*), divide (/), and remainder (%). Where subtraction can be used for integer data and real data operations, the remainder can only be used for integer data operations.

Three, self-increment self-decrement operator

The self-increment decrement operator includes:+ + 、--。

1, pre-operation: first increase or decrease after operation

+ + variable 、--variable

2, after the operation: first operation after the increase or decrease

Variable + +, variable--

Four-bit budget symbol


Five, comma operator

The comma operator can concatenate multiple expressions, and the comma-concatenated expression is called a comma-expression.

a=1,b=2,b++

Five. sizeof operator


Vi. Conforming Operators







This article from "Doublelinux" blog, declined reprint!

C-Language Summary----data type + operator + expression

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.