{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Chapter15solutions

# Chapter15solutions - Chapter 15 15.1 a#include ...

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

Chapter 15 15.1 a. #include <stdio.h> int main() { int i = 1; int sum = 0; while(i < 11) { sum = sum + i; ++i; } printf("%d\n",sum); } b. #include <stdio.h> int main() { int i; int sum = 0; for (i = 0; i <= 10; ++i) sum = sum + i; printf("%d\n",sum); } c. #include <stdio.h> int main() { int i = 0; int sum = 0; while(i < 11) sum = sum + i++; printf("%d\n",sum); } d. #include <stdio.h> int main() { int i = 0; int sum = 0; for(i = 0; i <= 10 ;) sum = sum + i++; printf("%d\n",sum); }

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

View Full Document
a. i = 0; j = 0; while (i < 5) { j = j + 1; i = j >> 1; } b. if(cont == 0) { a = 2; b = 3; } else { a = -2; b = -3; } c. #define LIMIT 5 if (LIMIT) printf("True"); else printf("False"); 15.3 #include <stdio.h> main() { int smallestNumber; int nextInput; scanf("%d",&nextInput); /* We need to set the initial value of smallestNumber to something other than 0 as in the original code */ smallestNumber = nextInput; while (nextInput != -1) { if (nextInput < smallestNumber) smallestNumber = nextInput; scanf("%d",&nextInput);
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

Chapter15solutions - Chapter 15 15.1 a#include ...

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

View Full Document
Ask a homework question - tutors are online