Homework 1 ENEE 114 Spring 2007 POSTED: Friday February 9 DUE: 11:59 pm Monday February 19 * name your answers as hw1.1.c, hw1.2.c, ..., and submit each of them via the GLUE submit command * make sure that you document each hw1.x.c file /****************************************************************************/ 1. Write down the UNIX commands to generate the following directory structure under your GLUE root directory. (You are highly recommended to do so too). For example, Proj1 is a subdirectory under Project, which is in turn a subdirectory of ENEE114, which is a subdirectory under your root This homework is posted at /dept/enee/public_html/class/enee114/homework with file name hw1.txt. Give the command that copies it to the HW1 subdirectory, assuming that you are now in the root directory. -root -ENEE114 -Project -Proj1 -Proj2 -Homework -HW1 -Quizzes -Recitation -Notes 2. Give the output of the following while loop: int i = 1; while ( i < 10 ) { printf("i = %d\n", i); i = i + 2; } what will be output if one switches the order of the two statements inside the while() loop? 3. Write a C program to print out the following nine lines of *'s: (Hint: you may consider to use while loops) z: a.out *** ** * ** **** ****** * ** *** z: 4. Write a program that asks user to input an integer x and decides whether x is positive or negative. Your program should stop when 0 is entered. For example, z: a.out Enter an integer (0 to stop): -2 -2 is negative. Enter an integer (0 to stop): 531 531 is positive. Enter an integer (0 to stop): 0 You entered 0. Good-bye! z: 5. Complete the following program so it will replace a character in the given sentence #include int main(void) { char s[] = "thisismyfirsthomeworkinENEE114"; ..... printf("Here is a sentence:\n%s\n", s); printf("Enter the position that you want to replace (0 to 29):"); .... } For example, the following shows the output of the completed program when the first i is replaced by t, z:a.out Here is a sentence: thisismyfirsthomeworkinENEE114 Enter the position that you want to replace (0 to 29):2 Enter the character that you want to replace 'i':t Here is the new sentence: thtsismyfirsthomeworkinENEE114 z: 6. Write a complete C program to ask the user to enter the number of quarters, dimes, nickels, and pennies and then create an output like the following: You have entered 2 quarters, 3 dimes, 4 nickels, and 1 pennies. There are 10 coins and their total value is $1.01. (Note: all coin names (quarters, dimes, nickels, and pennies) will be in plural even if you have 1 or none coin of that kind.)