C Language Review 1

Source: Internet
Author: User
Tags variable scope

Memory analysis of C language Variables C language addressing from large to small # include <stdio.h>

int main (int argc, const char * argv[]) {
int a = 100;
int b = 200;

printf ("The address of A is%d\n", &a);
printf ("The address of B is%d\n", &b);

return 0;
} out: The address of A is 1606416268
The address of B is 1606416264
-"4 bytes apart, from large to waiter/three, scanf function This is a blocking function # include <stdio.h>

int main (int argc, const char * argv[]) {
int a = 0;
printf ("Please input a num:");
scanf ("%d", &a);
printf ("The NUM is%d\n", a);

return 0;
} #include <stdio.h>

int main (int argc, const char * argv[]) {
int A;
int b;

printf ("Please input the first number:\n");
scanf ("%d", &a);
printf ("Please input the second number:\n");
scanf ("%d", &b);
printf ("The result is%d\n", A + B);

return 0;
} #include <stdio.h>

int main (int argc, const char * argv[]) {
int A;
int b;

printf ("Please input the numbers:");
scanf ("%d%d", &a, &b);
printf ("The result is%d\n", A + B);

return 0;
Precedence brackets for arithmetic operator operators > positive and negative > Math operations > Bit operations > Math VS > Logic VS > Conditional Operations > Assignment Operations v. Assignment operator compound assignment operator + =-+ *=/= vi. self-increment self-reduction a++ ++aa--a PS: No squared: a** a//Seven, sizeof output accounted for the number of bytes eight, the relational operation except 0 is true the return value is only 0 and 1, true is 1, false is 0 There are multiple operators, you can use the results 1 and 0 continue in order of precedence operation nine, logical operation The results of the logical operations are only 1 and 0 logical with: && logic or: | | Bit with: & Bit or: | Bit or: ^ #include <stdio.h>

int main (int argc, const char * argv[]) {
int result = 1 ^ 1;
printf ("result =%d\n", result);


return 0;
} out:result = 0 logical non:!  Any value is true and FALSE!!! 10 or three mesh operation Xx?xx:xx#include <stdio.h>

int main (int argc, const char * argv[]) {
int a = 10;
int B = 20;
int result = a>b?33:11;
printf ("result =%d\n", result);


return 0;
} out: result = OneXi. if basic use 12, if use note variable scope 13, switch condition can only be int or char defined variable in case, must be included with {}, or there will be compilation error # include <stdio.h>

int main (int argc, const char * argv[]) {
int a = 10;

Switch (a) {
Case 10:
{

int B = A + 1;
Break
}

Default
Break
}

return 0;
}

C Language Review 1

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.