READING for Week 0 Notes for lecture 1. Kernighan and Ritchie, 1.1 1.2 1.3 1.7 --------------------------------------------- EXERCISES for Week 0 1. Write a program that prints "hello world" 5 times. 2. Write a program that reads in two numbers and prints their sum. 3. Write a program that reads a decimal integer and prints out its value in octal. 4. Write a program that reads an octal integer and prints out its value in decimal. 5. Write a program that reads in a number and prints out "hello world" that many times. For discussion: How would you fix your program from exercise 2 to print "TOO BIG" if one or both of the numbers typed (or the resulting sum) is too big to be represented in the computer? Answers to Exercises for Week 0 1. #include main() { printf("hello, world\n"); printf("hello, world\n"); printf("hello, world\n"); printf("hello, world\n"); printf("hello, world\n"); } 2. #include main() { int x, y; scanf("%d %d", &x, &y); printf("%d\n", x+y); } 3. #include main() { int n; scanf("%d", &n); printf("%o\n", n); } 4. #include main() { int n; scanf("%o", &n); printf("%d\n", n); } 5. #include main() { int i, n; scanf("%d", &n); for (i = 0; i < n; i++) printf("hello, world\n"); }