Answer to Question #229852 in C++ for svj

Question #229852

WAP which displays a given character, n number of times, using a function. 

When the n value is not provided, it should print the given character 80 times. 

When both the character and n value is not provided, it should print ‘*’ character 80 times.

[Write the above program in two ways:- -using function overloading. -using default arguments.


1
Expert's answer
2021-08-26T02:26:15-0400
#include <iostream>
void displayChar(char x = '*', int n = 80) {
    for (int i = 0; i < n; i++) {
        std::cout << x;
    }
    std::cout << std::endl;
}
int main() {
    displayChar();
    displayChar('+');
    displayChar('-', 10);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS