Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include <iostream> #include <string> using namespace std; string STUDENT = \"ck

ID: 3791444 • Letter: #

Question

#include <iostream>
#include <string>
using namespace std;

string STUDENT = "ckim84"; // Add your Blackboard login name
extern string ASSIGNMENT;


/**
* Describe the purpose of your program here.
* @return 0 for success.
*/
int run()
{

repeatChar(3, "abcde$");
return 0;
}

string repeatChar(int n, const string& pat)
{
string result;
for (int i = 0; i < n; i++)
{
result += pat;
}
return result;
}

could you correct my code?? i got an error msg like below :

h02.cpp:22:1: error: use of undeclared identifier 'repeatChar'
repeatChar(3, "abcde$");
^
1 error generated.
make: *** [h02.o] Error 1

i tried to write a code to input some random values in the fuction. I think this way I did works on java, but for some reason, it doesnt work at all on c++.

Explanation / Answer

Program:

#include <iostream>
#include <string>
using namespace std;
string STUDENT = "ckim84"; // Add your Blackboard login name
extern string ASSIGNMENT;

/**
* Describe the purpose of your program here.
* @return 0 for success.
*/
/* int run()
{
return 0;
} */ // Here no need to write run method


string repeatChar(int n, const string& pat)
{
string result;
for (int i = 0; i < n; i++)
{
result += pat;
}
return result;
}
int main() {
repeatChar(3, "abcde$");
   return 0;
}

Output: Executed successfully