• Register
2 votes


Please find out the problem in my code and let me know where I am wrong.

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

string userInput();
int wordLengthFunction(string word);
int permutation(int wordLength);

int main()
    string word = userInput();
    int wordLength = wordLengthFunction(string word);

    cout << word << " has " << permutation(wordLength) << " permutations." << endl;

    return 0;

string userInput()
    string word;

    cout << "Please enter a word: ";
    cin >> word;

    return word;

int wordLengthFunction(string word)
    int wordLength;

    wordLength = word.length();

    return wordLength;

int permutation(int wordLength)
    if (wordLength == 1)
        return wordLength;
        return wordLength * permutation(wordLength - 1);


12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

1 vote


You should not be repeating the string part when sending parameters.

Write like this instead of the wrong one.

int wordLength = wordLengthFunction(word);


13 9 6
94,240 points

Related questions

0 votes
1 answer 22 views
problem: I'm new to C++ and programming, and have run into a mistake that I can't sort out. At the point when I attempt to run the program, I get the accompanying blunder message: stringPerm.cpp: In capacity 'int main()': stringPerm.cpp:12: mistake: expected ... int permutation(int wordLength) { if (wordLength == 1) { return wordLength; } else { return wordLength * permutation(wordLength - 1); } }
asked Feb 17 kaash_kashi 1.2k points
1 vote
1 answer 1 view
1 view
Problem: I&rsquo;m new to C++ , I made a simple ;program but I keep getting this error : expected primary-expression before 'enum' Can somebody tell me what is wrong with my code ? Code: #include<iostream> using namespace std; int main(){ //This is where codeblocks notes the error. enum board{'b','o','a','r','d'}; return 0; }
asked 1 hour ago Ashty 6k points
0 votes
1 answer 15 views
0 votes
1 answer 27 views
0 votes
1 answer 40 views
0 votes
1 answer 65 views
Problem : I want to compile my code to test my function to read and print the data file, but I get the compiling error that I don't understand as follows "Error: expected constructor, destructor, or type conversion before ';' token".
asked Jan 24, 2020 jwilliam 3.9k points
0 votes
1 answer 87 views
Problem Hey, I was writing a class for finding the average of grades outside the class but I Am facing an error named expected initializer before token. Can someone help me to resolve this error Here is my code Program:  #include <iostream> using std::cout; using std::cin; ...   computeAverage = computeAverage + gradeAverage.getGrade();     }     cout << computeAverage/5 << endl;     return 0; }
asked Dec 22, 2020 chris jordan 2.4k points
0 votes
1 answer 2 views
Problem: In the implementation file, I get the above error on line 2 of the implementation code. I have used this same exact syntax in another program with successful compilation and correctly functioning results, so I am quite confused. There are three different function ... their respective lines. I assume I am making a small error but I really can't seem to figure it out. PLease guide
asked Apr 7 Sana8989 8.9k points
1 vote
1 answer 3 views
Problem: While writing a Kerne;l I get this error while writiong a code on compiler. Error: expected &lsquo;=&rsquo;, &lsquo;,&rsquo;, &lsquo;;&rsquo;, &lsquo;asm&rsquo; or &lsquo;__attribute__&rsquo; before &lsquo;{&rsquo; token.
asked Mar 30 PkGuy 13.1k points
0 votes
1 answer 13 views
Problem: Please solve it &hellip; Because I am unable to find out the solution... error: a function-definition is not allowed here before &lsquo;{&rsquo; token
asked Mar 25 Ifra 24.4k points