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 int numRows = 1); and how many asterisks to print on each row. Default arguments are provided to display one row 7 8 int main ( ) of 10 asterisks. 9 { 10 displayStars ( ) ; // starsPerRow & Program 6-22 numRows use defaults (10 & 1) 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
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 int numRows = 1); and how many asterisks to print on each row. Default arguments are provided to display one row 7 8 int main ( ) of 10 asterisks. 9 { 10 displayStars ( ) ; // starsPerRow & Program 6-22 numRows use defaults (10 & 1) 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
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Please help me explain this
The output is:
Program Output
**********
*****
*******
*******
*******
Expert Solution
Step 1
While creating the function we can set the arguments of the function with some default value so that if the user forgets to pass the parameter while calling the function then the function is executed using the default values and no error has occurred.
Here also we have declared the function with default values.
Step by step
Solved in 2 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY