Hello, can you please help me understand what is wrong here? Goal is to print value of integer i. In case i is a multiple of 3, then print word "Fizz".
I am getting error:
main.cpp:14:6: error: ‘String’ in namespace ‘std’ does not name a type
std::String printNum() {
^~~~~~
main.cpp: In function ‘int main()’:
main.cpp:31:14: error: ‘printNum’ was not declared in this scope
==========================================================================
#include <iostream>
#include <string>
usingnamespace std;
std::String printNum() {
std::String result;
for (int i = 1; i < 101; i++) {
//If number is multiple of 3, print word 'Fizz'
if (i%3==0) {
result = "Fizz";
} else {
std::string result = to_string(i);
}
}
return result;
}
int main()
{
printNum();
return 0;
}