473,395 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

can anyone tell me where the infinite loop is and why it won't stop when I input zero

I need help with my homework....i have to write a program that inputs multiple lines of integer numbers and outputs them in an HTML table. The numbers should be printed 3 in a row, one number per column. And the last column is the sum. Input should stop when zero is entered. Zero shouldnt be output. Empty cells should be output to complete the table. and the last row should contain the sum of all numbers in each respective column and the total of all the numbers. I have started the code without the HTML tags but i have errors and it isn't working. this is what i have so far..... if anyone can help I would appreciate it. thanks

#include <iostream>
using namespace std;

int main() {
int input;
int InputCount=0;
int RowSize=2;
int ColumId = 0;



while((input <= -1)||(input >= 1));
{
cin>>input;
while (InputCount <= RowSize);
{

if (InputCount == 0);
ColumId =(InputCount % RowSize);
cout << ColumId << endl;
cout << input;
InputCount ++;
cin>>input;
if (input == 0);
cout << "done";

if (InputCount == 1);
ColumId =(InputCount % RowSize);
cout << ColumId << endl;
cout << input;
InputCount ++;
cin>>input;
if (input == 0);
cout << "done";

if (InputCount == 2);
ColumId =(InputCount % RowSize);
cout << ColumId << endl;
cout << input;
InputCount = 0;
cin>>input;
if (input == 0);
cout << "done";

}
}}
Oct 5 '06 #1
6 2261
#include <iostream>
using namespace std;

int main() {
int input;
int InputCount=0;
int RowSize=2;
int ColumId = 0;



while((input <= -1)||(input >= 1));
{
cin>>input;
while (InputCount <= RowSize);
{

if (InputCount == 0);
ColumId =(InputCount % RowSize);
cout << ColumId << endl;
cout << input;
InputCount ++;
cin>>input;
if (input == 0);
cout << "done";

if (InputCount == 1);
ColumId =(InputCount % RowSize);
cout << ColumId << endl;
cout << input;
InputCount ++;
cin>>input;
if (input == 0);
cout << "done";

if (InputCount == 2);
ColumId =(InputCount % RowSize);
cout << ColumId << endl;
cout << input;
InputCount = 0;
cin>>input;
if (input == 0);
cout << "done";

}
}}
Oct 5 '06 #2
Remove semicolon after while condition
Oct 5 '06 #3
Remove semicolon after while condition

thank you I think I was looking at it too long and was missing that. Thanks alot
Oct 5 '06 #4
Is it working fine now?
Oct 5 '06 #5
Is it working fine now?
yeah thanks i have to work on the spacing but its good I think Im good now
Oct 5 '06 #6
D_C
293 100+
Edit: Double post, same as here, where it appears the question was already answered.

I have a question, when a 0 is entered, is the sum always going to be blank? If I enter a, -a, and 0 for one row, the sum should be 0. Will 0 or an empty cell be printed? I assume an empty cell since it will be easier.
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.   int input;
  7.   int inputCount=0;
  8.   int rowSize = 4;
  9.   int sum = 0;
  10.  
  11.   do
  12.   {
  13.     cin>>input;
  14.     if(input == 0)
  15.       break; // should break the do while loop
  16.     cout << input << "\t";
  17.     // WriteCell(input)
  18.     sum += input;
  19.     inputCount++;
  20.  
  21.     if(inputCount == (rowSize-1))
  22.     {
  23.       cout << sum << endl;
  24.       // WriteCell(sum);
  25.       sum = 0;
  26.       inputCount = 0;
  27.     }
  28.   } while(true); // while(input != 0) if break doesn't work
  29.  
  30.   // I am assuming always put a blank cell for the last sum value
  31.   while(inputCount++ != rowSize)
  32.   {
  33.     cout << "\t";
  34.     // WriteBlankCell();
  35.   }
  36.   cout << endl;
  37. }
Oct 5 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
43
by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a...
1
by: yaru22 | last post by:
Hi. I'm using python-mode in emacs. I happened to execute the code that contains an infinite loop. The system is hung and it doesn't stop at all. lol How do I manually stop it in emacs?
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
10
by: =?ISO-8859-1?Q?G=E9rard_Talbot?= | last post by:
www.authoring.stylesheets] Dear fellow CSS colleagues and web authors in alt.html discussion forum, I would like to ask you to help me confirm that there is a serious bug in IE 7 final release...
33
by: dmoran21 | last post by:
Hi all, I am a mathematician and I'm trying to write a program to try out a formula that I've derived. However, it seems that I've got an infinite loop and I don't quite understand why. I was...
19
by: Richard | last post by:
Hi All, I copied a script example from http://www.irt.org/script/640.htm into a local .html file. I opened that file first in HTML-kit, which hung (in an infinite loop, I think) when I...
13
by: Sunbags | last post by:
Hello, I'm a 2nd year Computer Engineering student and I have a problem with my VB6 code. I've just started learning VB6 for a project in which we have to create a form which displays the...
12
by: Bill Mill | last post by:
Hello all, I want to have a user able to eval code in a text box. However, if he accidentally types "while(1) { i=0; }" and hits "run", I also want him to be able to hit a stop button such that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.