HW3 - Solutions

HW3 - Solutions - int i; int length;...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
EC327 Introduction to Software Engineering HW #3 Solutions Problem 1 [10 points] Problem 2 [10 points] /* pe6-1.c */ /* this implementation assumes the character codes */ /* are sequential, as they are in ASCII. */ #include <stdio.h> #define SIZE 26 int main( void ) { char lcase[SIZE]; int i; for (i = 0; i < SIZE; i++) lcase[i] = 'a' + i; for (i = 0; i < SIZE; i++) printf("%c", lcase[i]); printf("\n"); return 0; } /* pe6-3.c */ /* this implementation assumes the character codes */ /* are sequential, as they are in ASCII. */ #include <stdio.h> int main( void ) { char let = 'F'; char start; char end; for (end = let; end >= 'A'; end--) { for (start = let; start >= end; start--) printf("%c", start); printf("\n"); } return 0; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Problem 3 [10 points] Problem 4 [20 points] /* pe6-6.c */ #include <stdio.h> #include <string.h> int main( void ) { char input[81];
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int i; int length; printf(&quot;Enter a word: &quot;); scanf(&quot;%s&quot;, input); length = strlen(input); for (i = length - 1; i &gt;= 0; i--) printf(&quot;%c&quot;, input[i]); return 0; } /* pe6-16.c */ #include &lt;stdio.h&gt; #define WINNINGS 1.0E6 #define RATE_COMP 0.08 #define WITHDRAW 1.0e5 int main( void ) { double chuckie = WINNINGS; int years = 0; while (chuckie &gt; 0) { chuckie += RATE_COMP * chuckie; chuckie -= WITHDRAW; ++years; printf(&quot;Balance at end of year %2d: $%9.2f\n&quot;, years, chuckie); } printf(&quot;Investment values after %d years:\n&quot;, years); printf(&quot;Chuckie Lucky: $%.2f\n&quot;, chuckie); return 0; } Problem 5 [50 points] Step myVar myPtr *myPtr 1 0x00001234 0x20002c28 0x00000000 2 0x00001234 0x20002c28 0x00001234 3 0x0000abcd 0x20002c28 0x00001234 4 0x0000abcd 0x20002b28 0x0000abcd 5 0x000abcd0 0x20002b28 0x000abcd0 6 0x000abcd1 0x20002b2c unknown...
View Full Document

Page1 / 3

HW3 - Solutions - int i; int length;...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online