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
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: