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
#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;
}
Comments
Leave a comment