Transcript
PowerPoint 2
2
C (constant) (variable) .
, .
.
.
YES C 2
2.1
(character) , , , (character string) .
.
‘A’ ‘’() .
“ ”() , “1234” .
.
YES C 2
2.1.1
(ASCII) .
.
.
() ‘a’
() ‘\246’, ‘\x9B’
YES C 2
, (0x00~0x19) .
escape 2.1 .
YES C 2
2.1 escape
\a \b \f \n \r \t \v \' \" \\ \? \0dd \xhhh \0
Bell (alert) Backspace Formfeed New line Carriage return Horizontal tab Vertical tab Single quotation mark Double quotation mark Backslash Literal question mark ASCII character in octal notation ASCII character in hexadecimal notation Null character
YES C 2
2.1.2
, signed int.
‘u’, ‘U’ (tag) .
int long int .
long int .
unsigned long int ‘ul’ ‘UL’ .
‘0’ 8 ‘0x’ ‘0X’ 16 .
YES C 2
2.2

8
016, 077
16
0x1A, 0XFF
unsigned
12U, 077u, 0XFFU
± . u U .. 2(0~65535) .
long
077l, 0XFFL
YES C 2
2.1.3
double.
.
YES C 2
2.3


long double
YES C 2
2.1.4
(character string constant) , .
“ ”() .
(Null) . “abc" 3 4.
“" 0 (null string). 1.
YES C 2
2.4



signed int signed long unsigned int unsigned long
132, -743, 0xf3c -74L, 2378l, -3000000000, 0xFFFFL 74u, 2378u, 0274u 74ul, 2378ul, 0x2e4ul

float double long double
0.1f, -20.5f, 2.f, 13e1F, -3.57E-02f 0.1, -20.5, 2., 13e1, -3.57E-02 0.1l, -20.5L, 2.l, 13e1L, -3.57E-02L

2.2
(variable) .
.
.
2.2.1

.
‘=’ .
.
YES C 2
,
.
31 .
(_) .
(if, int, for, do....) .
.
YES C 2
2.5


avg_12 sum ptr1 ptr2 JUMSU key_item
if → for → 67kk → +hit → (+) ?pp → (?) jan-item → –
YES C 2


int i, j; //FORTRAN i, j, k, l ,m, n
char a, b, c;
char *n, *q, *r;
float x, y z;
()

.
PutImage, SetColor, GetCurrenFileName, ....
HandleCalculation, ProcessData, ...
. .
YES C 2
()
9~15. 15~20 .
. .
=>
2.2.2
.
.
YES C 2
2.6 , . .
#include <stdio.h>
#include <conio.h>
void main(void)
printf("%c\n",a);
for(i=a;i<=122;i++)
2.3


, , .
)
y=x+1;
x 1 y .
‘=’ .
2.8 . .
#include <stdio.h>
#include <conio.h>
void main(void)
k = (i=20) + (j=40); /* */
printf("i = %d, j = %d, k = %d\n",i, j, k);
}
2.4 (data type)

.
YES C 2
2.4.1
2byte signed int .
int signed long int .
long .
unsigned int .
YES C 2
2.6 (int) (Visual C++ )
int
Byte

int signed int unsigned int short int signed short int unsigned short int long int signed long int unsigned long int
4 4 4 2 2 2 4 4 4
-2147483648 - 2147483647 -2147483648 - 2147483647 0 - 4294967295 -32768 - 32767 -32768 - 32767 0 - 65535 -2147483648 - 2147483647 -2147483648 - 2147483647 0 - 4294967295
YES C 2
2.4.2
char
1 1 1
YES C 2
2.4.3
float, double, long double double.
float 32bit , 1 8, 23 3 .
float 10 7.2 10+38 .
float double long double .
YES C 2
IEEE 754 float
2.8 (float) (Visual C++ )
S


1
YES C 2
2.9 .
#include <stdio.h>
void main()
2.5







#include <stdio.h>
void main(void)
float f;
printf("c=%d \n", c);
printf("f=%f \n", f);
2.6
:
C : printf, scanf

#include <stdio.h>
: , (type) .
YES C 2
2.6.1 printf
printf .

)
2.9 printf


%x, %X
%u
%s
%p
2.10 printf
0
#
0 : 0 x or X : 0x or 0X e, E, f, g or G : g G 0 .

.
h
short
l
long
L
2.12 printf
#include <stdio.h>
void main() {
printf("%7.1f\n",789.45); // 789.5
printf("%20s\n","abcdefg789.45"); //
2.6.2 scanf

)
2.11 scanf

%o
%u
%c
: . \0 . .
%s
%e,%f,%g
[^…]
%%
YES C 2
2.13 scanf
#include <stdio.h>
result = scanf( "%d %f %c %s", &i, &fp, &c, s );
printf( "\n = %d\n",result);
}
#include <stdio.h>
void main(void)
char c;
printf(" input(integer)==>");
}
#include <stdio.h>
void main(void)
}
2.16
#include <stdio.h>
void main(void)
2.17 miles kilometers
1 mile = 1.609 km
}
2.18
#include <stdio.h>
void main(void)
printf(“a = %10d\n”, a); /* 10 */
printf(“a = %-10d\t”, a); /* 10 */
printf(“a = %3d\n”, a);
printf(“float f = %f\t”, f);
printf(“float f = %12.5f\t”, f);
}
2.7
.
getchar() :
putchar() :
YES C 2
int getchar( );
EOF
EOF
int *gets(char *str );
: str
int puts(char *str );
: 0
: EOF
#include <stdio.h>
void main(void)
putchar(); /* */
}
2.21 gets, puts .
#include <stdio.h>
void main(void)
#include <stdio.h>
void main(void)
c=getchar();
putchar(c);

Top Related