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

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

View Full Document Right Arrow Icon
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); }
Background image of page 1

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

View Full DocumentRight Arrow Icon
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);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This homework help was uploaded on 04/07/2008 for the course ECE 495K taught by Professor Vijaykumar during the Spring '08 term at Purdue University-West Lafayette.

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 Right Arrow Icon
Ask a homework question - tutors are online