/* * Selftest2 * Chapter 5 * John Stile */ 1. Correct errors in each statement if any. 1a. scanf("%d\n", &num); 1b. scanf("%d", &num); scanf("%s", str); 2. What is printed as the output of the following program fragment? int xx =07; // declare and assign 7 to memory location of xx printf("%d:, xx); // look at what is sotred at memory location of xx, and print as decimal printf("%.3d\n", xx); // look at what is sotred at memory location of xx, and print as decimal, // but pad to 3 digits (i.e. 003) 3. Write a program which outputs the following result when the user inputs a float. The 3.14 in italic means the user input value. Enter a float number: 3.14 The number 3.14 consists of 3 and 14 The sum of two pars is 17 Use scanf function to obtail the needed pieces (3 dot 17). Make the program work without using %f specifier. Answer: See selftest2_prob3.c 4. Write a program, which converts every instance of space characters to a newline character when the user redirects a file or pipes the output Answer: See selftest2_prob4.c