? 1
int main(void) int a; int b; a=3; b=a+5; printf("a : %d \n", a); printf("b : %d \n", b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf(" a : %x \n", &a); printf(" b : %x \n", &b); * : 12ff60, 12ff54 2 a : 3 b : 8 a : 12ff60 b : 12ff54
- (Operator): - (Operand): 3
= +, -, *, /, % +=, -=, *=, /=, %= ++, -- >, <, ==,!=, >=, <= &&,,!? : &,!, ^, ~ >>, << 4
( ) (=) - - 5
( ) (=) - - i = 3 5
( ) (=) - - i = 3 i 3 5
( ) int main(void) int i=0, j=0, k=0; printf("i = %d, j = %d, k = %d \n", i, j, k); i = 1; j = 5; k = 7; printf("i = %d, j = %d, k = %d\n", i, j, k); i=0, j=0, k=0 i=1, j=5, k=7 6
( ) : (+), (-), (*), (/), (%) +( ) a = 6+2 6 2 -( ) a = 6-2 6 2 *( ) a = 6*2 6 2 /( ) a = 6/2 6 2 %( ) a = 6%2 6 2 7
( ) int main(void) int a, b; a = 6; b = 2; printf(" : %d \n", a+b); printf(" : %d \n", a-b); printf(" : %d \n", a*b); printf(" : %d \n", a/b); printf(" : %d \n", a%b); : 8 : 4 : 12 : 3 : 0 8
( ) int main(void) int num1, num2; num1 = 10/3; // ' ' num2 = 10%3; // ' ' printf(" : %d \n", num1); printf(" : %d \n", num2); : 3 : 1 9
( ) a = a + b a += b a + b a a = a b a -= b a - b a a = a * b a *= b a * b a a = a / b a /= b a / b a a = a % b a %= b a % b a 10
( ) int main(void) int num1=1, num2=2, num3=3, num4=4, num5=5; num1 = num1 + num2; // num1 += num2; num2 = num2-2; // num2 -= 2; num3 = num3 * 2; // num3 *= 2; num4 = num4 / 2; // num4 /= 2; num5 = num5 % 2; // num5 %= 2; printf("%d, %d, %d, %d, %d \n",num1,num2,num3,num4,num5); 3, 0, 6, 2, 1 11
( ) ++, -- ( 1 1 ) ++a a++ --a a--, ( ), ( ), ( ), ( ) 12
( ) int main(void) int num1=10; printf("%d \n", num1);// 10 num1++; // num1 = num1 + 1; printf("%d \n", num1);// 11 ++num1; // num1 = num1 + 1; printf("%d \n", num1);// 12 --num1; // num1 = num1-1; printf("%d \n", num1); // 11 num1--; // num1 = num1-1; printf("%d \n", num1);// 10 13 10 11 12 11 10
( ) int main(void) int num1=10, num2=10; int a, b; a = ++num1; //, printf("%d, %d \n", a, num1); // 11, 11 b = num2++; //, printf("%d, %d \n", b, num2); // 10, 11 11, 11 10, 11 14
( ) int main(void) int num1=10, num2=10; int a, b; num1 = num1 + 1; // a = num1; // printf("%d, %d \n", a, num1); // 11, 11 b = num2; // num2 = num2 + 1; // printf("%d, %d \n", b, num2); // 10, 11 11, 11 10, 11 15
( ) int main(void) int num1=10, num2=10; printf("%d \n", ++num1); // 11 printf("%d \n", num1);// 11 printf("%d \n", num2++); // 10 printf("%d \n", num2);// 11 11 11 10 11 16
( ) (True) (False) > a>b a b 1( ), 0( ) < a<b a b 1( ), 0( ) >= a>=b a b 1( ), 0( ) <= a<=b a b 1( ), 0( ) == a==b a b 1( ), 0( )!= a!=b a b 1( ), 0( ) 17
( ) int main(void) int num1=2, num2=4; int result1, result2, result3, result4; result1 = (num1 > num2); result2 = (num1 <= num2); result3 = (num1 == num2); result4 = (num1!= num2); printf("result1 %d \n", result1); // 0( ) printf("result2 %d \n, result2); // 1( ) printf("result3 %d \n", result3); // 0( ) printf("result4 %d \n", result4); // 1( ) result1 0 result2 1 result3 0 result4 1 18
( ) &&: AND ( ) : OR ( )! : NOT ( ) 0 && 0 0( ) 0 && 1 0( ) 1 && 0 0( ) 1 && 1 1( ) 19
( ) 0 0 0( ) 0 1 1( ) 1 0 1( ) 1 1 1( )!! 0 1( )! 1 0( ) 20
( ) int main(void) int num1=2, num2=3, num3=5; int result1, result2, result3; result1 = (num1>0) && (num2<10); result2 = (num2<=2) (num3>5); result3 =!num3; printf("result1 %d \n", result1); // 1( ) printf("result2 %d \n", result2); // 0( ) printf("result3 %d \n", result3); // 0( ) result1 1 result2 0 result3 0 21
( ) 22
( ) int main(void) int a=1, b=2; printf("hello ), printf("world! \n"); a++, b++; printf("%d, a), printf( %d, b), printf( \n"); Hello World! 2 3 23
( )? : 24
( ) int main(void) int num1=2, num2=3; int result1; result1 = (num1>num2)? num1 : num2; printf("result1 %d \n",result1); : 3 7 25
1 () [] ->. 8 & 9 ^ 2 ~ ++ -- + - * & 10 3 * / % 11 && 4 + - 12 5 << >> 13?: 6 < <= > >= 14 = += -= *= /= %= &= ^=!= <<= >>= 7 ==!= 15, 26
1). : 10 + 20 = 30 int main(void) printf("%s %d \n,, 10 + 20 ); 27
1). : 10 + 20 = 30 int main(void) printf("%s %d \n, 10 + 20 =, 10 + 20 ); 28
2). : This year is 2011. I m 20 years old. I was born in 1991. int main() const int year1 = 2011; const int year2 = 1991; const int age = 20; printf( ); printf( ); printf( ); 29
2). : This year is 2011. I m 20 years old. I was born in 1991. int main() const int year1 = 2011; const int year2 = 1991; const int age = 20; printf("%s %d%c \n", "This year is", year1,'.'); printf("%s %d %s \n", "I'm", age, "years old."); printf("%s %s %s %s %d%c \n", "I", "was", "born", "in", year2, '.'); 30
3) a, ASCII A. int main() int a_char = 'a'; int A_char = a_char - ; printf("the ASCII code of a is %d. \n", ); printf("the ASCII code %d is the character. \n",, ); 31
3) a, ASCII A. include<stdio.h> int main() int a_char = 'a'; int A_char = a_char - 32; printf("the ASCII code of a is %d. \n", a_char); printf("the ASCII code %d is the character %c. \n", A_char, A_char); : The ASCII code of a is 97. The ASCII code 65 is the character A. 32
4)., equal.. : input : 5 input : 2 Smaller Number : 2 int main() int num1; int num2; int result; printf("input : "), scanf("%d", &num1); printf("input : "), scanf("%d", &num2); result = (num1 > num2)? num2 : num1; (num1 == num2)? printf("equal \n") : printf("smaller Numer: %d. \n", result);? 33
4)., equal.. : input : 5 input : 2 Smaller Number : 2 int main() int num1; int num2; int result; printf("input : "), scanf("%d", &num1); printf("input : "), scanf("%d", &num2); result = (num1 > num2)? num2 : num1; (num1 == num2)? printf("equal \n") : printf("smaller Numer: %d. \n", result); 34
C 5 : 3, 4, 7, 8, 9 : 2011 3 30 9 : void main(). scanf_s. 35