include include using namespace std string STUDENT ckim84

#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++.

Solution

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

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site