lesson 7 cin long c
[[lesson_7_cin_long_c]] last edit on
Aug 10, 2005
3:17 AM
by rescued_by_c
[user02@FC4 Lesson07]$ cat -n cin_long.c
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: 666666666666
The number you typed was 2147483647
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: -8888888888
The number you typed was -2147483648
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: abc
The number you typed was 134513676
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: .56
The number you typed was 134513676
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: 0.56
The number you typed was 0
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: 12.34
The number you typed was 12
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: -.5
The number you typed was 134513676
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: -1024.89
The number you typed was -1024
[user02@FC4 Lesson07]$
1 #include <stdio.h>
2
3 int main(void)
4 {
5 long value;
6
7 printf("Type a large number and press Enter: ");
8 scanf("%ld", &value);
9 printf("The number you typed was %ld\n", value);
10
11 return 0;
12 }
[user02@FC4 Lesson07]$ gcc -o cin_long cin_long.c[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: 666666666666
The number you typed was 2147483647
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: -8888888888
The number you typed was -2147483648
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: abc
The number you typed was 134513676
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: .56
The number you typed was 134513676
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: 0.56
The number you typed was 0
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: 12.34
The number you typed was 12
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: -.5
The number you typed was 134513676
[user02@FC4 Lesson07]$ ./cin_long
Type a large number and press Enter: -1024.89
The number you typed was -1024
[user02@FC4 Lesson07]$