To implement the function with default arguments.
The algorithm to solve the above problem:
1. Start
2. Declare the default function.
3. Invoke the default function.
4. Display the result
5. Stop
Implementation of above problem in C++:
#include<iostream>
using namespace std;
void printLine(char ='%', int = 40);
int main()
{
printLine();
printLine('#');
printLine('*',30);
printLine('M',20);
return 0;
}
void printLine(char ch, int count)
{
int i;
cout<<endl;
for(i=0;i<count;i++)
{
cout<<ch;
}
}
The output of the above program is tested on www.jdoodle.com
Output:
%%%%%%%%%%%%%%%%%%%%
####################
***************
MMMMMMMMMM
Thanks
Mukesh Rajput
Post A Comment:
0 comments: