[user02@FC4 Lesson06]$ cat -n mathover.c
1 #include <stdio.h>
2
3 int main(void)
4 {
5 int result;
6
7 result = 200 * 300;
8
9 printf("200 * 300 = %d\n", result);
10
11 return 0;
12 }
[user02@FC4 Lesson06]$ gcc -o mathover mathover.c[user02@FC4 Lesson06]$ ./mathover
200 * 300 = 60000
[user02@FC4 Lesson06]$ cat -n mathover2.c
1 #include <stdio.h>
2
3 int main(void)
4 {
5 short result;
6
7 result = 200 * 300;
8
9 printf("200 * 300 = %d\n", result);
10
11 return 0;
12 }
[user02@FC4 Lesson06]$ gcc -o mathover2 mathover2.c[user02@FC4 Lesson06]$ ./mathover2
200 * 300 = -5536
[user02@FC4 Lesson06]$ cat -n mathover3.c
1 #include <stdio.h>
2
3 int main(void)
4 {
5 int result;
6
7 result = 200000 * 300000;
8
9 printf("200000 * 300000 = %d\n", result);
10
11 return 0;
12 }
[user02@FC4 Lesson06]$ gcc -o mathover3 mathover3.cmathover3.c: In function ?emain?f:
mathover3.c:7: warning: integer overflow in expression
[user02@FC4 Lesson06]$ ./mathover3
200000 * 300000 = -129542144
[user02@FC4 Lesson06]$
lesson_6_mattover.c, Rev. 1, Last changed on 2005-08-09 02:29, 296 page hits