expression ? expression1 : expression2 ;
a += 4; b <<= 1;
int i = 4.3; float f = 3; int g = 0; int h = 0; f = 3.7; g = i + f + .4; h = (int) i + (int) f + (int) .4;
(int) 29.55 + (int) 21.99 is the same as 29 + 21 in C
while (expression) statement for (expr1; expr2; expr3) statement do statement while (expression);
if (expression)
statement1
else
statement2
switch (expression) {
case const-expression: statements
case const-expression: statements
default: statements
}
int i[5]; i[0] = i[1] = 1; i[2] = 2; i[i[2] + 1] = i[2] + 2; i[i[2] + i[2]] = i[3] + i[2];
int i, a[10];
// clear or copy all values
for ( i = 0; i < 10; i++ ) {
a[i] = 0; or a[i] = x[i];
}
unsigned short int a[10] = {1, 2, 3, 4, 5, 6, 0, 0, 0, 0};
unsigned short int a[10] = {1, 2, 3, 4, 5, 6};
unsigned short int a[] = {1, 2, 3, 4, 5, 6, 0, 0, 0, 0};
unsigned short int a[] = {[0]=1, [1]=2, [2]=3, [3]=4, [4]=5,
[5]=6, [9]=0};
int i, j;
float a[3][10] = { {14.2, 1, 0, 9.4},
{0, 144, 7, 2.5},
{2, 3, 109, 42.0} };
for (j = 0; j < 10; j = j + 1)
printf("\t%d:", j);
printf("\n");
for (i = 0; i < 3; i = i + 1) {
printf("%d:", i);
for (j = 0; j < 10; j = j + 1)
printf("\t%f", a[i][j]);
printf("\n");
}
char hello[] = {'h', 'e', 'l', 'l', 'o', '!'};
\n a "newline" character (linefeed, ctrl-j) \b a backspace \r a carriage return (without a line feed, ctrl-m) \' a single quote (e.g., in a character constant) \" a double quote (e.g., in a string constant) \\ a single backslash