Script started on Mon Sep 16 13:01:28 2024 mweeks@air:csc3320$ cd .. mweeks@air:Desktop$ cp hello.c scanf_ex1.c mweeks@air:Desktop$ vi scanf_ex1.c mweeks@air:Desktop$ cat scanf_ex1.c /* scanf */ #include int main (int argc, char *argv[]) { int num,count = 0; printf("Enter a number\n"); // in-line comment count = scanf("%d", &num); printf("Scanf returned value %d, and number is %d\n", count, num); return 0; } mweeks@air:Desktop$ gcc scanf_ex1.c -o scanf_ex1 mweeks@air:Desktop$ ./scanf_ex1 Enter a number 4 Scanf returned value 1, and number is 4 mweeks@air:Desktop$ ./scanf_ex1 Enter a number Scanf returned value -1, and number is 0 mweeks@air:Desktop$ mv csc3320/example.c example_var_types.c mweeks@air:Desktop$ cat example_var_types.c #include int main() { printf("Type char in C has %lu bytes\n", sizeof(char)); printf("Type short in C has %lu bytes\n", sizeof(short)); printf("Type int in C has %lu bytes\n", sizeof(int)); printf("Type long in C has %lu bytes\n", sizeof(long)); printf("Type long long in C has %lu bytes\n", sizeof(long long)); printf("Type float in C has %lu bytes\n", sizeof(float)); printf("Type double in C has %lu bytes\n", sizeof(double)); printf("Type long double in C has %lu bytes\n", sizeof(long double)); } mweeks@air:Desktop$ vi fourbit.txt mweeks@air:Desktop$ cat fourbit.txt 0000 0 0 0001 1 1 0010 2 2 0011 3 ... 0100 4 0101 5 0110 6 0111 7 7 1000 8 -8 1001 9 -7 1010 10 -6 1011 11 -5 1100 12 -4 1101 13 -3 1110 14 -2 1111 15 -1 1110 1's complement of 1110 is 0001 add 1 1 ---- 0010 under 2's complement, 1110 is -2 1111 1's complement of 1111 is 0000 add 1 1 ---- 0001 under 2's complement, 1111 is -1 with this, fill in 3rd column if 8 bits, range is -128 to +127, or 0 to 255 (unsigned) if 16, -32768 to +32767 mweeks@air:Desktop$ gcc example_var_types.c -o example_var_types mweeks@air:Desktop$ ./example_var_types Type char in C has 1 bytes Type short in C has 2 bytes Type int in C has 4 bytes Type long in C has 8 bytes Type long long in C has 8 bytes Type float in C has 4 bytes Type double in C has 8 bytes Type long double in C has 16 bytes mweeks@air:Desktop$ sftp snowball.cs.gsu.edu mweeks@snowball.cs.gsu.edu's password: Connected to snowball.cs.gsu.edu. sftp> put example_var_types.c Uploading example_var_types.c to /home/mweeks/example_var_types.c example_var_types.c 100% 602 152.5KB/s 00:00 sftp> quit mweeks@air:Desktop$ ^ftp^sh^ ssh snowball.cs.gsu.edu mweeks@snowball.cs.gsu.edu's password: Last failed login: Sat Sep 14 22:52:48 EDT 2024 from c-76-97-124-159.hsd1.ga.comcast.net on ssh:notty There were 3 failed login attempts since the last successful login. Last login: Thu Sep 12 17:46:33 2024 from c-24-99-154-26.hsd1.ga.comcast.net + | GSU Computer Science | Instructional Server | SNOWBALL.cs.gsu.edu + [mweeks@gsuad.gsu.edu@snowball ~]$ gcc example_var_types.c -o example_var_types [mweeks@gsuad.gsu.edu@snowball ~]$ ./example_var_types Type char in C has 1 bytes Type short in C has 2 bytes Type int in C has 4 bytes Type long in C has 8 bytes Type long long in C has 8 bytes Type float in C has 4 bytes Type double in C has 8 bytes Type long double in C has 16 bytes [mweeks@gsuad.gsu.edu@snowball ~]$ exit logout Connection to snowball.cs.gsu.edu closed. mweeks@air:Desktop$ vi onesandtwos mweeks@air:Desktop$ cat onesandtwos 1111 find the 2's complement: - find the 1's complement 0000 - add 1 to the 1's complement 0001 0 * 2^3 + 0 * 2^2 + 0 * 2^1 + 1 * 2^0 1 0101.101 convert to decimal 0 * 2^3 + 1 * 2^2 + 0 * 2^1 + 1 * 2^0 + 1 * 2^-1 + 0 * 2^-2 + 1 * 2^-3 4 + 1 + 1/2 + 1/8 mweeks@air:Desktop$ exit exit Script done on Mon Sep 16 13:40:01 2024