Exercise help - Raindrops

Hello, I am learning C++.
I started solving the Raindrops problem in the C++ learning track.
But I am stuck on it for a few days now.
Could somebody please review my code and the error I am getting and help me make some sense to it? And guide to towards solving this problem.

My code:

#include "raindrops.h"
#include <string>

namespace raindrops {
    string convert(int x) {
        string result = "";
        if (x%3==0) {
            result += "Pling";
        }

        if (x%5==0) {
            result += "Plang";
        }

        if (x%7==0) {
            result += "Plong";
        }

        else {
            result += to_string(x)
        }
        return result;
    }

}  // namespace raindrops

unfortunately due to the word limit, I am unable to paste the error I am getting.

My setup is simply the exercism’s web editor.

I would appreciate any help that I could get.
Thanks!

Take a look at the relation of the if / else clauses, is that how it suppose to work?

Ok i see two mistakes

  1. semiclona was missing after to_string
  2. Thanks for pointing that out. I am only applying else to the number x being indivisible by 7. That’s not what we desire.

Here’s my updated code:

#include "raindrops.h"
#include <string>

namespace raindrops {
    string convert(int x) {
        string result = "";
        if (x%3==0) {
            result += "Pling";
        }

        if (x%5==0) {
            result += "Plang";
        }

        if (x%7==0) {
            result += "Plong";
        }

        if (x%3!=0 && x%5!=0 && x%7!=0) {
            result += to_string(x);
        }
        return result;
    }

}  // namespace raindrops

however I am getting the following error now:

error: 'convert' is not a member of 'raindrops'

Could you please assist me here?

Perhaps you have not added the function declaration to raindrops.h

You have not shown us that file.

You might need to edit it to have #include <string> and somewhere contain a function declaration.