Download presentation
Presentation is loading. Please wait.
1
CS150 Introduction to Computer Science 1
Summary Last Time: We looked at nested loops. Important Dates: Assignment due on Wednesday, October 15, 2003 Exam on Friday, October 17, 2003 2/22/2019 CS150 Introduction to Computer Science 1
2
CS150 Introduction to Computer Science 1
Nested Loops A loop within a loop. Each time the outer loop is repeated, the inner loop is reentered, their loop control components are reevaluated, and all required iterations are performed. 2/22/2019 CS150 Introduction to Computer Science 1
3
CS150 Introduction to Computer Science 1
What’s the Output for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) cout << “*”; cout << endl; } 2/22/2019 CS150 Introduction to Computer Science 1
4
CS150 Introduction to Computer Science 1
What’s the Output for (int i =m; i >0; i--) { for (int j = n; j>0; j--) cout << “*”; cout << endl; } 2/22/2019 CS150 Introduction to Computer Science 1
5
CS150 Introduction to Computer Science 1
Problem Write a program that outputs a rectangle of stars for any inputted width and height 2/22/2019 CS150 Introduction to Computer Science 1
6
CS150 Introduction to Computer Science 1
Problem Write the nested ‘for’ loops that output the following: * ** *** **** ***** 2/22/2019 CS150 Introduction to Computer Science 1
7
CS150 Introduction to Computer Science 1
Problem Write a program to play the stones game. There are 13 stones and 2 players alternate taking 1, 2 or 3 stones per turn. The winner is the player to remove the last stone. The program should print out (using *’s) a picture of how many stones are left each turn. 2/22/2019 CS150 Introduction to Computer Science 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.