Error with output

closed account (i8bjz8AR)
So I'm building and running my program successfully with no errors, but when I enter values, after the last one, the output screen does something weird and scrolls all the way to the bottom, then when i scroll back up, nothing is there... Any ideas? I'm using codeblocks (c++11). Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main(int argc, char const *argv[])
{
	int index, temp;
	string salsa[5] = {"mild", "medium", "sweet", "hot", "zesty"};
	int jars[5];

	for (index = 0; index!=5; index++)
	{
		cout << "Please enter the number of jars of " << salsa[index] << " salsa sold in the past month: ";
		cin >> jars[index];
	}

	cout << "================================================================================" << endl;
	cout << "=====================================REPORT=====================================" << endl;
	cout << "================================================================================" << endl;
	cout << endl;

	cout << left << setw(40) << "Salsa" << right << setw(40) << "# sold" << endl;
	for (index = 0; index!=5; index++)
	{
		cout << left << setw(40) << salsa[index] << right << setw(40) << jars[index] << endl;
	}

	cout << endl << left << setw(40) << "Total # sold:" << right << setw(40) << jars[0]+jars[1]+jars[2]+jars[3]+jars[4] << endl;

	for(index = 0; index < 5; index++)
    {
        if(jars[index]>temp)
        	temp=jars[index];
    }

    cout << left << setw(40) << "Highest selling product:" << right << setw(40) << salsa[index] << endl;

    for(index = 0; index < 5; index++)
    {
        if(jars[index]<temp)
        	temp=jars[index];
    }

    cout << left << setw(40) << "Lowest selling product:" << right << setw(40) << salsa[index] << endl;

	return 0;
}
Is it supposed to scroll down? and what you see when it scrolls down is that it is continuously scrolling down and after it scrolls longer than the page it deletes what comes off the top.
Last edited on
Your program starts scrolling at the Highest selling Product output. if you set line 38 and line 46 as comments the screen will stop scrolling. In those lines is the error that is causing it to continuously scroll. I believe the error is the use of right
Topic archived. No new replies allowed.