Advanced Programming 2009 1
C Language Types dimensions
type bytes char 1 or 2 short 2 int 2 or 4 long 4 float 4 double 8 long double 10
- Dimension of int type depends on platform
and compiler
- char type must be smaller than int type
C Language Types dimensions type bytes char 1 or 2 short 2 - - PDF document
Advanced Programming 2009 C Language Types dimensions type bytes char 1 or 2 short 2 int 2 or 4 long 4 float 4 double 8 long double 10 Dimension of int type depends on platform and compiler char type must be smaller than
dot or exponent (es. 12e-3) or dot and exponent
F, f => float constant L, l => long double constant
5
6
7
If the value is equals to 0 condition false If the value is different from 0 condition true
8
Arithmetical
Relational
Return 1 for true, 0 for false
Assignment
Increment
Prefix ( ++x ) and postfix ( x++ )
Unary operators (i.e. with one operand, like ++, --) have
Arithmetical operators have precedence on relational
9
&& (and) || (or) ! (not) ^ (xor, i.e. exclusive-or)
& | ^ (and, or, xor) << (left-shift) >> (right-shift) ~
10
&& (and) has precedence on || (or) ! (not) is unary operator and has
What’s the value of ‘y’ ?
#include <stdio.h> int main( ) { int numbers[5] = {74, 18,33,30,97}; int result[5], index; char line[80]; /* sprintf builds a string „line‟ out of many elements */ sprintf(line,"%d %d %d %d %d\n", numbers[0],numbers[1],numbers[2],numbers[3],numbers[4]); printf("%s",line); /* sscanf parses many elements from a string „line‟ */ sscanf(line,"%d %d %d %d %d", &result[4],&result[3],(result+2),(result+1),result); for (index = 0;index < 5;index++) printf("The final result is %d\n",result[index]); getchar(); }
15
16
17
18