To all of those who are im sure sick of me and all my questions, heres one more.
Here is my program, remember this is my first menu type and i am getting errors compiling it. Could some help me out?
ThanksCode:#include <iostream.h> int main() { int resp, x, a; float num, val; char num2, cont; for(;;) x = 0; { cout << " Conversion Program" << endl; cout << " ==================" << endl; cout << " Option Description" << endl; cout << " ------ ---------------------" << endl; cout << " 0 Quit" << endl; cout << " 1 Binary - Decimal" << endl; cout << " 2 Decimal - Binary" << endl; cout << " Please choose an option." << endl; cin >> resp; if (resp == 0) break; switch(resp) { case 1: cout << "Binary - Decimal..." << endl; cout << "Enter the number needing converting:" << endl; cin << num; Val = (Num / 10000000.0); if(Val >= 1.0) { cout << "Has to be under 8 numbers long!" << endl; break; } else a= num % 10; if (a = 1) { x = x + 1; } num2 = num2 / 10; a= num % 10; if (a = 1) { x = x + 2; } num2 = num2 / 10; a= num % 10; if (a = 1) { x = x + 8; } num2 = num2 / 10; a= num % 10; if (a = 1) { x = x + 16; } num2 = num2 / 10; a= num % 10; if (a = 1) { x = x + 32; } num2 = num2 / 10; a= num % 10; if (a = 1) { x = x + 64; } num2 = num2 / 10; a= num % 10; if (a = 1) { x = x + 128; } cout << "The number in Decimal is: " << x; break; case 2: cout << "Decimal - Binary..." << endl; cout << "Enter the number needing converting:" << endl; cin << num; if (num > 255) { cout << "Number cannot be larger than 255!" << endl; break; } if (num >= 1) { num = num - 1; x = x + 1; } if (num >= 2) { num = num - 2; x = x + 10; } if (num >= 4) { num = num - 4; x = x + 100; } if (num >= 8) { num = num - 8; x = x + 1000; } if (num >=16) { num = num - 16; x = x + 10000; } if (num >= 32) { num = num - 32; x = x + 100000; } if (num >= 64) { num = num - 64; x = x + 1000000; } if (num >= 128) { num = num - 128; x = x + 10000000; } cout << "The number in Binary is: " << x; break; default; cout << "Invalid Response!!" << endl; break; cout << "Type a 'c' to continue..." << endl; cin >> cont; } return 0; }



LinkBack URL
About LinkBacks



. The compiler tells you on which row the error is (+/- 1) so it shouldn't be too hard to find them.
.