This is a two part question;
I am attempting to write a code which will output a number in its txt form, for example if the input in 10 it outputs ten, if the input is 22 it outputs twenty-two.
Now, yesterday it appeared I had this project complete. I could execute the code and it behaved exactly like I wanted it to. However, since installing cygwin the code doesnt appear to be behaving in the same way. When i try to compile it now explains to me that i need a parenthesis after the else if statement containing a condition, and even once I Include this, else if (tens >=2), the program no longer outputs correctly for numbers above 19.
In conclusion, my questions are, Why is the compiler functioning so differently now, is this a good or a bad thing, and of course, i am curious as to what exactly is faulty about the code. Any hints or advice will be more than appreciated;
Code:// Computer Science - Lab 2b // Outputing Text Format of Numbers 10-99 // Adam Davis - 09/06/09 #include <iostream> using namespace std; int main() { cout << "Enter a Number Between 10-99: "; char tens, ones; cin >> tens >> ones; if (tens = 1) { switch (ones) { case '0' : cout << "Ten"; break; case '1' : cout << "Eleven"; break; case '2' : cout << "Twelve"; break; case '3' : cout << "Thirteen"; break; case '4' : cout << "Fourteen"; break; case '5' : cout << "Fifteen"; break; case '6' : cout << "Sixteen"; break; case '7' : cout << "Seventeen"; break; case '8' : cout << "Eighteen"; break; case '9' : cout << "Nineteen"; break; } } else if { switch (tens) { case '2' : cout << "Twenty"; break; case '3' : cout << "Thirty"; break; case '4' : cout << "Fourty"; break; case '5' : cout << "Fifty"; break; case '6' : cout << "Sixty"; break; case '7' : cout << "Seventy"; break; case '8' : cout << "Eighty"; break; case '9' : cout << "Nintey"; break; default: cout << "Number not within allowed range" << endl; } switch (ones) { case '0' : cout << " "; break; case '1' : cout << " one"; break; case '2' : cout << " two"; break; case '3' : cout << " three"; break; case '4' : cout << " four"; break; case '5' : cout << " five"; break; case '6' : cout << " six"; break; case '7' : cout << " seven"; break; case '8' : cout << " eight"; break; case '9' : cout << " nine"; break; default: cout << "Number not within allowed range" << endl; } } }