C Programming Languages-types, operators and expressions -2.1----variable names, data types and lengths, constants, declarations, arithmetic operators, relational operators, and logical budget characters

Source: Internet
Author: User
Tags arithmetic arithmetic operators logical operators

Preface: Continue the C Series.



1. Variable name

Variable name Nothing to say, simply filtered.

2. Data type and length



Handwriting trouble, a direct screenshot. Let's take a look at an example: Write a program to determine the char, short, int, long types that are qualified by signed and unsigned respectively

The range of variables to be evaluated. Implemented using the corresponding values in the print standard header file. Directly give the print program:



ANSI C standard stipulates that each type of range of values must be defined in header file <limits.h>. short, int, long types have different lengths on different hardware, so their range of values on different machines tends to be different.

3. Constant

The constants in the C language are similar to those in Java, but there is a big difference.

In general, there are several categories of constants: an integral constant, or an integer. Two. Real-type constants. Three. Character-type constants. Four. String constants, note that string constants and character-type constants are not the same.   Now look at the details of what the constants are like.   Integral constant integer constants can be in three different ways: 1. Decimal integers. such as 356,-120,0. 2. Eight in-process integers. Constants in octal form begin with 0, such as 0123, which is the decimal 83;-011, which is the decimal-9. 3.16 in-process integers. Hexadecimal constants start with a 0x, such as 0x123, which is 291 of the decimal.   Two there are two types of solid constant Real constants: 1 decimal decimal form. We should be familiar with this, primary school, but note: 0.0 is also a real constant. 2. Exponential form. A junior high school should know the scientific counting method, the exponential form of the constant is another expression of scientific notation, such as 123000, with the scientific notation for the 1.23x10 of the 5-time side, In the C language is 1.23e5 or 1.23E5, note that E or E must be preceded by a number, and E or E after the number must be an integer.   three. character-type constant character constants are "enclosed" and can be expressed in two ways: 1. General form. A character is enclosed in a "', note that only one character can be used. 2. Special form. Special forms are the beginning, they will not be directly displayed on the screen, but according to their specific functions to display, these special characters constants: \n   line, the equivalent of knocking a carriage return. \t   jumps to the next tab position, which is equivalent to clicking the TAB key on the keyboard. \b   backspace, which is equivalent to clicking BACKSPACE. \r   the cursor back to the beginning of the bank. \f   the page, the cursor moves to the beginning of the next page. \\   output \ Character, which is to display a \ character on the screen. \ '    output ' character, which is displaying a ' character on the screen. \ "   output" character, which is to display a "character on the screen." \ddd  1 bits to the 3-bit octal number of characters.        For example: Using ' \376 ', a black square is displayed on the screen. A character that is represented by a \xhh  1 bit to a 2-bit hexadecimal number. Notice that x can't be lost.   Four. String constant string constants and wordsThe difference in constants is that the string constants are enclosed by "", so ' a ' and ' a ' are not the same, and the system automatically adds a string-ending flag (' ") at the end of the string constant.

4. Relational operators and logical operators


This concludes our study today.


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.