Learn the second day of C language!

Source: Internet
Author: User

Today is still watching the tutorial while reading the case study C language ~

Just came to meet a trouble, after watching the curtain friends of the discussion only to find a blind spot of their own do not know!

1. "=": Indicates assignment!! "= =" means equal!!

Force Conversion code type        double a=3.14     // define floating-point variable and assign 3.14 to a printf (theinteger portion of "A is%d/n" (  int) a) output: The integer part of a is 3 /* Note: 1, the conversion will not change the original data type and variable value, only in this operation temporarily converted. 2. The result of the cast operation does not follow the rounding principle. 

2. Unresolved issues

#include <stdio.h>int main () {    int x, y;    x = ten;    y =-3;    printf ("x+y=%d\n", X+y     );      printf ("x-y=%d\n", X-y     );    printf ("x*y=%d\n", X*y     );    printf ("x/y=%d\n", X/y     );    printf ("x%%y=%d\n", x%y     );       Why this line is preceded by x%%y instead of X%y    return 0;          }                       Teacher Answer:% character escape character is percent, want to output% need to use percent.
Similar to line break output to use \ n where \ is the escape character

3. Note: The self-increment and decrement operators change the original value

For example:    int x = 0;                           if: Inx x = 0    printf ("x=%d\n", x + +);          printf ("x=%d\n", ++x)    printf ("x=%d\n", ++x);          printf ("x=%d\n", X + +)    outputs the result: 0    2                   The output is: 1    1

Law:

3. There are spaces between the symbols in a simple assignment statement, and no spaces between the two consecutive symbols in a compound assignment statement!

For example://Use simple assignment statements to achieve x multiplied by 2.
x = x * 2;
Use a compound assignment statement to achieve y multiplied by 2.
Y *= 2;

Learn the second day of C language!

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.