A First C Program (Mixing Datatypes) : Department of Computer and Information Science, School of Science, IUPUI
A First C Program (Mixing Datatypes) : Department of Computer and Information Science, School of Science, IUPUI
A First C Program
(mixing datatypes)
Dale Roberts, Lecturer
Computer Science, IUPUI
E-mail: [email protected]
Dale Roberts
int
double
Examples
Example: c: char, u: unsigned, i: int, d: double, f:float,
s: short, l: long,
Expression
c s / i
int
unsigned
u * 3 i
Explanation
u * 3.0 i
double
unsigneddouble, double*double,
intdouble, double-double=double
c + i
int
double
long
char int
c + 1.0
3 * s * l
Dale Roberts
Dale Roberts
3.
(type) expr
Example:
float f=2.5;
x = (int)f + 1;
/* the result is 3, Q: will f value be changed? */
4.