473,379 Members | 1,184 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,379 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 2259
#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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.