/* * Assignment * Chapter 6 * By John Stile */ Assignemnt 1. If the following code is included in a program what will the outcome be and why? aa=6; if ( aa <= 5 ) printf ("The value of aa"); printf("is less than or equal to 8"); else printf("aa is greater than 5"); Answer: compile error. error: expected expression before else you need braces between the if and the else when you have more than one statment between. Assignment 2. Explain how the following code fragments work: a) gg=' '; // assign a space to variable gg // assumed to be a previously declared char variable while ( (aa=getchar() ) != gg ) // get character from standard in // assign result ing value to address of aa // while the value in aa the same as the value of gg, // execute the next command printf("%c", aa); // print the ascii value in aa b) switch(bb) // consider the value in bb for this switch satment case 'A': mmnnoo(); // if bb holds ascii value 'A' , call function mmnnoo break; // exit switch block 3) In the SELFTEST, you completed the digitconverter.c and evenorodd.c programs. Explain how each works. Include sample output with our verison of the programs. Please see comments in attached programs Ran: who | ./digitcounter Output: The number of digits input: 79 Ran: ./evenorodd Input: Enter an integer: 20 Output: The number 0 is even Input: Enter an integer: 21 Output: The nubmer 0 is odd Input: Enter an integer: 20.5 Output: That is not an integer: 20.500000 Input: Enter an integer: 0 Output: Zero is not even or odd. it's zero