advice with a program

Hello, I'm new to c++ programming. I would like some help on a program i made up. its a word solver. I want to input the number of letters the word has, then c++ finds which word matches the number of letters it has. i keep getting a error on line 26(the last else). Later on, when i get better at c++ i want to add more words and questions, but for now this is all i can come up with. any help and advice is welcome.

//word solver
#include <iostream>
#include "conio.h"
#include <string>
using namespace std;

void main()
{
string numLetters;
int misalignment = 12;
int appendage = 9;
int decorous = 8;

cout << "How many letters does the word have?" << endl;
cin >> numLetters;
getline(cin, numLetters);
cin.clear();

if(numLetters == "12"){
cout << "Is misalignment your word?" <<endl;
}

else if(numLetters == "9"){
cout << "Is your word appendage?" << endl;
}

else(numLetters == "8"){
cout << "Is your word decorous?" << endl;
}



_getch();
}
You forgot to put the last IF.

else if (numLetter == "8")

Just because it is the last else, it still has something to compare so you need the if statement. That should fix your problem.
thanks nickburress2k2, but now when i debug nothing comes out after i input the number of letters. did i leave anything out?
I don't know what you mean by using string but using int works fine for me.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//word solver
#include <iostream>
#include "conio.h"

using namespace std;

int main()
{
int numLetters;

cout << "How many letters does the word have?" << endl;
cin >> numLetters;
cin.clear();

if(numLetters == 12){
cout << "Is misalignment your word?" <<endl;
}

else if(numLetters == 9){
cout << "Is your word appendage?" << endl;
}

else if(numLetters == 8)
{
cout << "Is your word decorous?" << endl;
}

return 0;
_getch();
}

thanks for the help mainframe639, i"m still new to programming.
Last edited on
Topic archived. No new replies allowed.