Answer to Question #235196 in C++ for makwapa

Question #235196

Write a method that accepts a string and integer n as arguments, the method then displays the passed string n times. Example, if we pass “Testing” as a string and 4 as the integer, the function will display; Testing Testing Testing Testing Write a main() method demonstrating that the method works correctly by calling it twice, firstly with your first name and last digit on your student number, and secondly with your last name, and the sum of the last two digits on your student number


1
Expert's answer
2021-09-10T23:52:26-0400
#include <iostream>


using namespace std;


void func(string s, int n){
    for(int i=0;i<n;i++){
        cout<<"\n"<<s;
    }
}
int main()
{
    func("Smith",5);
    func("Smith",8);


    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