commit 73953fdb119db95c91da4581490e6996437b169f from: jrmu date: Sat Jan 17 19:56:41 2026 UTC Import sources commit - /dev/null commit + 73953fdb119db95c91da4581490e6996437b169f blob - /dev/null blob + a839d8f54b802567f23849f55621c47861478a60 (mode 644) --- /dev/null +++ 1-1.c @@ -0,0 +1,10 @@ +/* +1-1. Run the "hello, world" program on your system. Experiment with leaving out parts of the program, to see what error messages you get. +*/ + +#include + +int main() +{ + printf("hello, world\n"); +} blob - /dev/null blob + 48e083557f3fd4b452e32261706af3a6e3bd4ef4 (mode 644) --- /dev/null +++ 1-2.c @@ -0,0 +1,24 @@ +/* +1-2. Experiment to find out what happens when printf's argument string contains \c, where c is some character not listed above. +*/ + +#include + +int main() +{ + printf("Alert\a\n"); + printf("Back\b\bspace\n"); + printf("Formfeed and more text\f"); + printf("Carriage return\r"); + printf("\tHorizontal tab\n"); + printf("Vertical tab\v"); + printf("Some text\n"); + printf("Backslash\\\n"); + printf("Question mark\?\n"); + printf("Single quote\'\n"); + printf("Double quote\"\n"); + printf("%d == 0123 is 83 in octal\n", 0123); + printf("\123 == \\123 is S in ASCII\n"); + printf("%d == 0x123 is 291 in hexadecimal\n", 0x123); + printf("\x23 == \\x23 is # in ASCII\n"); +} blob - /dev/null blob + ec1fae672cd0bcea0bd25c741466cdd65b60b7bb (mode 644) --- /dev/null +++ 1-3.c @@ -0,0 +1,26 @@ +/* 1-3 Modify the temperature conversion program to print a heading above the table */ + +#include + +/* print Fahrenheit-Celsius table + for fahr = 0, 20, ..., 300; floating-point version */ +int main() +{ + float fahr, celsius; + int lower, upper, step; + + lower = 0; /* lower limit of temperature table */ + upper = 300; /* upper limit */ + step = 20; /* step size */ + + fahr = lower; + + printf("Fahr | Celsius\n"); + printf("=====+========\n"); + + while (fahr <= upper) { + celsius = (5.0/9.0) * (fahr-32.0); + printf(" %3.0f | %6.1f\n", fahr, celsius); + fahr = fahr + step; + } +} blob - /dev/null blob + 8266c81e12ca6a96d0ae9b8f1191b4ccaf60e1c3 (mode 644) --- /dev/null +++ 1-4.c @@ -0,0 +1,26 @@ +/* 1-4 Write a program to print the corresponding Celsius to Fahrenheit table. */ + +#include + +/* print Celsius-Fahrenheit table + for celsius = -20, 0, ..., 160; floating-point version */ +int main() +{ + float fahr, celsius; + int lower, upper, step; + + lower = -20; /* lower limit of temperature table */ + upper = 160; /* upper limit */ + step = 20; /* step size */ + + celsius = lower; + + printf("Celsius | Fahr \n"); + printf("========+========\n"); + + while (celsius <= upper) { + fahr = (9.0/5.0) * celsius + 32.0; + printf(" %3.0f | %3.0f \n", celsius, fahr); + celsius = celsius + step; + } +} blob - /dev/null blob + 42bf7af089eac307efb0135ca8c22d1491de93e9 (mode 644) --- /dev/null +++ 1-5.c @@ -0,0 +1,27 @@ +/* 1-5 Modify the temperature conversion program to print the table in reverse + * order, that is, from 300 degrees to 0. */ + +#include + +/* print Fahrenheit-Celsius table + for fahr = 300, 280, ..., 0; floating-point version */ +int main() +{ + float fahr, celsius; + int lower, upper, step; + + upper = 300; /* upper limit of temperature table*/ + lower = 0; /* lower limit */ + step = 20; /* step size */ + + fahr = upper; + + printf("Fahr | Celsius\n"); + printf("=====+========\n"); + + while (fahr >= lower) { + celsius = (5.0/9.0) * (fahr-32.0); + printf(" %3.0f | %6.1f\n", fahr, celsius); + fahr = fahr - step; + } +} blob - /dev/null blob + 5076026e8966084deb5ca13bdc9ff36857e3f418 (mode 644) --- /dev/null +++ 1-6.c @@ -0,0 +1,12 @@ +/* 1-6 Verify that the expression getchar() != EOF is 0 or 1. */ + +#include + +int main() +{ + int i; + while ((i = getchar() != EOF)) { + printf("%d", i); + } + printf("%d", i); +} blob - /dev/null blob + 44c5f20f8fcf9c084a0c911b4ce3da8a4d3b9862 (mode 644) --- /dev/null +++ 1-7.c @@ -0,0 +1,8 @@ +/* 1-6 Write a program to print the value of EOF */ + +#include + +int main() +{ + printf("%d\n", EOF); +} blob - /dev/null blob + 2eef88e39e244b31e7c3a11b9b7758db261b54a9 (mode 755) Binary files /dev/null and a.out differ