Computer Forums C++ Inputs and ASCII

 07-11-2006, 05:03 PM #1 Daemon Poster     Join Date: Jan 2005 Posts: 609 C++ Inputs and ASCII I am currently taking an Intro to C++ course at my local community college. I have been coding a program, in which I have the following: cout<<"Please enter in a three-digit number: "; cin<
 07-12-2006, 02:38 PM #2 Fully Optimized     Join Date: May 2004 Posts: 2,718 Re: C++ Inputs and ASCII Can you post your whole program please? And I hope that "cin <<" isn't on purpose. __________________ __________________ hackthissite.org (criticalsecurity.net) | gentoo.org The best argument against evolution are creationists themselves. They prove that life is devolving rather than evolving.
 07-12-2006, 02:43 PM #3 Daemon Poster     Join Date: Jan 2005 Posts: 609 Re: C++ Inputs and ASCII Yah. That was kind of by accident. It's a bit too late now, but I'd like to know anyways. // Dennis Ai // CSC133-GW // Lab03.cpp // This program will determine if the digits of a 3-digit number are odd or even. #include #include int main() { //local declarations int Number, HDCalc, TDCalc, UDCalc, TDQuotient, HDQuotient; int OddCounter, EvenCounter, ZeroCounter; OddCounter = 0; EvenCounter = 0; ZeroCounter = 0; cout<<"___________________________________________ ___________________________"<>Number; //Determine unit digit's odd/even attribute UDCalc = Number % 2; if (UDCalc==1) OddCounter++; else if (UDCalc==0) { UDCalc = Number % 10; if (UDCalc==0) ZeroCounter++; else EvenCounter++; } //Determine ten digit's odd/even attribute TDCalc = Number / 10; TDQuotient = TDCalc % 2; if (TDQuotient==1) OddCounter++; else if (TDQuotient==0) { TDCalc = TDCalc % 10; if (TDCalc==0) ZeroCounter++; else EvenCounter++; } //Determine hundred digit's odd/even attribute HDCalc = Number / 100; HDQuotient = HDCalc % 2; if (HDQuotient==1) OddCounter++; else if (HDQuotient==0) { HDCalc = HDCalc % 10; if (HDCalc==0) ZeroCounter++; else EvenCounter++; } //Rewrite three-digit number cout<<"The three-digit number you entered was: "<=1) && (ZeroCounter>=1)) cout<<"The number contains odd and zero digits."; else if ((EvenCounter>=1) && (ZeroCounter>=1)) cout<<"The number contains even and zero digits."; else if ((OddCounter>=1) && (EvenCounter>=1)) cout<<"The number contains both odd and even digits."; cout<
 07-13-2006, 02:38 AM #4 Daemon Poster     Join Date: Dec 2004 Posts: 595 Re: C++ Inputs and ASCII i cannot reproduce your problem... the whole enter 3 digits 00x and get it to equal zero... i always get the value of the number i enter. maybe you can explain to us how to get the error? __________________ Windows: A thirty-two bit extension and GUI shell to a sixteen bit patch to an eight bit operating system originally coded for a four bit microprocessor and sold by a two-bit company that can't stand one bit of competition.
 07-13-2006, 07:02 AM #5 Daemon Poster     Join Date: Jan 2005 Posts: 609 Re: C++ Inputs and ASCII It's just 008 and 009? __________________ Athlon FX-55 San Diego 2.6GhZ OCed to 3.0GhZ | Mushkin Redline XP 2x1GB PC4000 DDR500 3-3-2-8 OCed to 250MhZ | Seagate Barracuda SATA 400GB 7200RPM HDD | evGA GeForce 6800GT 350/1000 OCed to 425/1150
 07-13-2006, 12:55 PM #6 Daemon Poster     Join Date: Dec 2004 Posts: 595 Re: C++ Inputs and ASCII well i've tried 008 and 009 and other numbers with two zeros preceding it, still can't get the error. i tried with the code you've supplied and just a simple cin >> var; cout << var; program, always comes out the correct value. __________________ __________________ Windows: A thirty-two bit extension and GUI shell to a sixteen bit patch to an eight bit operating system originally coded for a four bit microprocessor and sold by a two-bit company that can't stand one bit of competition.