/*=======================================================================*/ #define PROGRAMMER "SOLUTIONS, Nofrills" #define PROG_CODE "SOLN" #define COURSE "ECE-1021" #define YEAR (2004) #define TERM "Fall" #define SECTION (0) #define ASSIGNMENT "HW#0" #define REVISION (0) #define TITLE "Hello World!" #define SUBTITLE "Last Modified on 16 AUG 04" #define EMAIL "ece1021@eas.uccs.edu" #define FILENAME "0_0SOLN0.c" /*=======================================================================*/ /*=======================================================================*/ /* WAIVED COMPILER WARNINGS */ /*=======================================================================*/ /* Linker Warning: No module definition file specified: using defaults Reason for Waiver: Can't suppress. Does not have adverse impact. */ /*=======================================================================*/ /* NOTES TO THE USER/GRADER */ /*=======================================================================*/ /* */ /*=======================================================================*/ /* PROBLEM STATEMENT */ /*=======================================================================*/ /* Write a program that, using only putc() generates the following message on the screen: Hello World! My Code's "SOLN" This message follows the output of PrintHeader() and is lined up on the left with it. */ /*=======================================================================*/ /* DEVELOPMENT NOTES */ /*=======================================================================*/ /* Must use \' to print a single quote. Choose to use \" to print a double quote. */ /*=======================================================================*/ /* PSEUDOCODE */ /*=======================================================================*/ /* 1) TASK: Print First Line 1.1) PUT: Two spaces to line up left edge with header 1.2) PUT: Hello World! (use code from Programming Lesson #1) 2) TASK: Print Second Line 2.1) PUT: Two spaces to line up left edge with header 2.2) PUT: Print My ID's "SOLN" (use \' and \" to print quotes) */ /*=======================================================================*/ /* DEVIATIONS FROM SUBMITTED PSEUDOCODE */ /*=======================================================================*/ /* No deviations */ /*=======================================================================*/ /*=======================================================================*/ /* CODE SECTION */ /*=======================================================================*/ /*=======================================================================*/ /*== INCLUDE FILES ======================================================*/ #include /* stdout, putc(), printf() */ /*== MACRO DEFINITIONS (OBJECT-LIKE) ====================================*/ #define FALSE (0) #define TRUE (!FALSE) #define BLANKLINE printf("\n") /*== EXIT CODE DEFINITIONS ==============================================*/ #define EXIT_PASS (0) #define EXIT_FAIL (1) /*== MACRO DEFINITIONS (FUNCTION-LIKE) ==================================*/ /*== TYPEDEF STATEMENTS =================================================*/ /*=======================================================================*/ /* STRUCTURE DEFINITIONS and FUNCTIONS */ /*=======================================================================*/ /*=======================================================================*/ /* SUPPORT FUNCTIONS ( functions not called directly by main() ) */ /*=======================================================================*/ int printc(char c, int n) { while ( (n--) && (c == putc(c, stdout)) ); /* EMPTY LOOP */ return n; } /*=======================================================================*/ /* PRIMARY FUNCTIONS ( functions called directly by main() ) */ /*=======================================================================*/ /*== FUNCTION PROTOTYPES (to Document Support Functions) ================*/ int printc(char c, int n); /*== PRIMARY FUNCTIONS ==================================================*/ void PrintHeader(void) { printc(' ', 2); printc('=', 76); putc('\n', stdout); printf(" Course....... %s-%i (%s %i)\n", COURSE, SECTION, TERM, YEAR); printf(" Programmer... %s (%s)\n", PROGRAMMER, PROG_CODE); printf(" Assignment... %s (Rev %i)", ASSIGNMENT, REVISION); printf(" (Source Code in %s)\n", FILENAME); printf(" Description.. %s\n", TITLE); printf(" %s\n", SUBTITLE); printc(' ', 2); printc('=', 76); putc('\n', stdout); return; } /*=======================================================================*/ /* MAIN FUNCTION */ /*=======================================================================*/ /*== FUNCTION PROTOTYPES (to Document Primary Functions) ================*/ void PrintHeader(void); int main(void) { /* Variable Declarations */ /* Executable Code */ PrintHeader(); BLANKLINE; putc(' ', stdout); putc(' ', stdout); putc('H', stdout); putc('e', stdout); putc('l', stdout); putc('l', stdout); putc('o', stdout); putc(' ', stdout); putc('W', stdout); putc('o', stdout); putc('r', stdout); putc('l', stdout); putc('d', stdout); putc('!', stdout); putc('\n', stdout); putc(' ', stdout); putc(' ', stdout); putc('M', stdout); putc('y', stdout); putc(' ', stdout); putc('I', stdout); putc('D', stdout); putc('\'', stdout); putc('s', stdout); putc(' ', stdout); putc('\"', stdout); putc('S', stdout); putc('O', stdout); putc('L', stdout); putc('N', stdout); putc('\"', stdout); putc('\n', stdout); return EXIT_PASS; } /*=======================================================================*/ /* END OF SOURCE CODE FILE */ /*=======================================================================*/