3_Answers_6_2_while-1

3_Answers_6_2_while- - CIS 15AG Answers Chapter 6 Repetitions(while 1 7 Code the following flow chart fragment then predict the output when x = 3 y

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

View Full Document Right Arrow Icon
CIS 15AG Answers Chapter 6: Repetitions (while) 7. Code the following flow chart fragment, then predict the output when x = 3, y = 13, and x = 13, y = 3. 8. Predict the output. char x = 'A'; while ( x < 'E' ) printf("%c\n", x++ ); char x = 'A'; while ( x < 'E' ) printf("%c\n", ++x ); 1 x y True READ x, y WRITE x x x - y int x, y; printf("Enter x and y: "); scanf("%d %d", &x, &y); while ( x >= y ) x = x – y; printf("Now x is %d", x ); x y x y Output 3 13 False 3 No iterations! -10 False -10 x y x y Output 13 3 True 10 True 7 True 4 True 1 False 1 4 iterations! Output A B C D Output B C D E
Background image of page 1

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

View Full DocumentRight Arrow Icon
CIS 15AG Answers Chapter 6: Repetitions (while) 9. Write a function for the following flow chart. All parameters are int . The first two are input parameters and the last two are output parameters. Desk-check the algorithm for x = 17, y = 5, then for x = 5, y = 17. What problem does this algorithm solve? 2 True x x - y q q + 1 q 0 x guess(x, y, q, r) return r x void quess( int x, int y, int *q, int *r ) { *q = 0;
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 note was uploaded on 09/02/2011 for the course CIS 15BG taught by Professor Staff during the Spring '10 term at DeAnza College.

Page1 / 5

3_Answers_6_2_while- - CIS 15AG Answers Chapter 6 Repetitions(while 1 7 Code the following flow chart fragment then predict the output when x = 3 y

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