2_Questions_6_3_for-1

# 2_Questions_6_3_for-1 - CIS 15AG Questions Chapter 6:...

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

CIS 15AG Questions Chapter 6: Repetitions (for) 14.Write a C function to print n asterisks using while , then using for . 1 void printStars(int n) { int i; return; } True i i + 1 i 1 i WRITE '*' printStars(n) return void printStars(int n) { int i; for ( ; ; ) return; } void printStars(int n) { for ( ; ; ) return; }

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

View Full Document
CIS 15AG Questions Chapter 6: Repetitions (for) 15. Write a C function to print all even numbers between 2 and n. void printEven(int n) { int i; for ( ; ; ) return; } 16. This function prints all even numbers between 2 and n. How would you grade it on a scale from 1 (worst) to 10 (best)? void printEven ( int n ) { int i; for ( i = 2; i <= n ; i++ ) { if ( i % 2 == 0 ) printf("%d ", i ); } return; } 17. Write a C function to print all odd numbers between 5 and n. void printOdd(int n) { int i; for ( ; ; ) return; } 2
CIS 15AG Questions Chapter 6: Repetitions (for) 18. Write a fragment of code to print the following numbers: 200 195 190 185 180 … 10 5 0 int i; for (

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

View Full Document
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 / 6

2_Questions_6_3_for-1 - CIS 15AG Questions Chapter 6:...

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

View Full Document
Ask a homework question - tutors are online