explain this program to me. For example, why this program wrote like this and etc. please give me as much details as you can. Thank you

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please explain this program to me. For example, why this program wrote like this and etc. please give me as much details as you can. Thank you

3 using namespace std;
4
Program 6-22
tion arguments. It has a function that displays aster-
isks on the screen. This function receives arguments
illustrates the use of default func-
5 // Function prototype with default argu-
ments
6 void displayStars(int starsPerRow =
10,
specifying how many rows of asterisks to display
= 1);
int numRows
and how many asterisks to print on each row.
7
Default arguments are provided to display one row
of 10 asterisks.
8 int main( )
9 {
10
displayStars();
// starsPerRow &
numRows use defaults (10 & 1)
Program 6-22
11
cout <« endl;
12
displayStars (5);
// starsPerRow 5.
numRows uses default value 1
1 // This program demonstrates the use of
13
cout <« endl;
default function arguments.
14
displayStars(7, 3); // starsPerRow 7.
2 #include <iostream>
Page 1,493
Page 1,494
5 pages left in this chapter
Transcribed Image Text:3 using namespace std; 4 Program 6-22 tion arguments. It has a function that displays aster- isks on the screen. This function receives arguments illustrates the use of default func- 5 // Function prototype with default argu- ments 6 void displayStars(int starsPerRow = 10, specifying how many rows of asterisks to display = 1); int numRows and how many asterisks to print on each row. 7 Default arguments are provided to display one row of 10 asterisks. 8 int main( ) 9 { 10 displayStars(); // starsPerRow & numRows use defaults (10 & 1) Program 6-22 11 cout <« endl; 12 displayStars (5); // starsPerRow 5. numRows uses default value 1 1 // This program demonstrates the use of 13 cout <« endl; default function arguments. 14 displayStars(7, 3); // starsPerRow 7. 2 #include <iostream> Page 1,493 Page 1,494 5 pages left in this chapter
numRows 3. No defaults used.
15
return 0;
16 }
24 void displayStars(int starsPerRow, int
17
numRows )
18
25 {
26
// Nested loop. The outer loop con-
trols the rows and
19
displayStars
27
// the inner loop controls the number
of stars per row.
20
This function displays a rectangle
28
for (int row
1; row <= numRows;
made of asterisks.
*
row++)
21
If arguments are not passed to it, it
29
{
uses the default *
30
for (int star
1; star <= stars-
22
arguments 10 for starsPerRow and 1
PerRow; star++)
for numRows.
31
cout <<
23
32
cout <« endl;
Page 1,495
Page 1,496
3 pages left in this chapter
Transcribed Image Text:numRows 3. No defaults used. 15 return 0; 16 } 24 void displayStars(int starsPerRow, int 17 numRows ) 18 25 { 26 // Nested loop. The outer loop con- trols the rows and 19 displayStars 27 // the inner loop controls the number of stars per row. 20 This function displays a rectangle 28 for (int row 1; row <= numRows; made of asterisks. * row++) 21 If arguments are not passed to it, it 29 { uses the default * 30 for (int star 1; star <= stars- 22 arguments 10 for starsPerRow and 1 PerRow; star++) for numRows. 31 cout << 23 32 cout <« endl; Page 1,495 Page 1,496 3 pages left in this chapter
Expert Solution
Step 1

The usage of default function parameters is demonstrated in this example. It features a feature that makes asterisks appear on the screen. This function takes two arguments: the number of asterisk rows to display and the number of asterisks to print on each row. To show one row of ten asterisks, default parameters are supplied.

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education