Confused - HELP PLEASE

thank you
Last edited on
@WheatFieldOnFire how would i implement that? Could you please help me with writing the actual loop for it?
Consider using a for loop.
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
int main()
{
    const int NUM_STORES = 5;
    // no need to declare the same variable multiple times
    // = { 0 } : sets all the elements to 0
    // = { 1 } : note that this only sets the first element to 1
    // and the rest are uninitialised
    int stores[NUM_STORES] = { 0 };

    // to keep track of total sales
    int total_sales = 0;
    // for every store
    for( int i = 0; i < NUM_STORES; i++ ) {
        // ask for input
        // store input in stores array
        // add to total_sales
    }

    int num_stars = 0;
    // calculate how many stars you need to print

    // use a for loop as shown above the print required stars

    system("pause");
    return 0;
}
how about something like this? i only did day one, but you could figure it out from here. i also cut out the end half of your code since i'm just demonstrating the for loop and how you can use it.

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
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	int store_1, store_2, store_3, store_4, store_5;
	int formula1, formula2, formula3, formula4, formula5;
	int counter = 0;
	cout << "Enter today's sales for store 1: ";
	cin >> store_1;
	cout << "Enter today's sales for store 2: ";
	cin >> store_2;
	cout << "Enter today's sales for store 3: ";
	cin >> store_3;
	cout << "Enter today's sales for store 4: ";
	cin >> store_4;
	cout << "Enter today's sales for store 5: ";
	cin >> store_5;

	
	
	for (int y; store_1 >= 100; store_1 -= 100)
	{
		cout << "*";
	}
return 0;
}


p.s. there is a way to use the for loop and not create the new variable (y in this case), i just don't remember ATM
Last edited on
p.s. there is a way to use the for loop and not create the new variable (y in this case), i just don't remember ATM

You just leave it blank.
for ( ; store_1 >= 100; store_1 -= 100 )
Topic archived. No new replies allowed.