HEY GUYS!!!!
8D so im learning C++ on my own and i signed up for game institutes 5 year program thing. o u o
so i basically have just me and a textbook to learn from and one of the exercises is to make a average calculator and i sorta figured out how to do it using a for loop. P: but theres a problem. e.e
its not stopping when its supposed to. it just keeps going. and its really irritating meeeeeee
D8 help me out here guyzzzzz
it wont perform as intended past 2. if you input 2 as the amount of numbers you want. then it will do the job. but if you put in 4. the loop keeps going on and on. and never ends. e.e and then i get some sorta error saying the stack is corrupt.
I also tried using a break statement, but same thing e.e it just ignores it and keeps looping
#include <iostream>
#include <string>
using namespace std;
//average calculator
int main()
{
int a;
float avrg[]{1};
float quo = 0;
cout << "Enter the amount of numbers youre going to average: ";
cin >> a;
for (int x = 0; x < a; )
{
cout << "[" << x << "] = ";
cin >> avrg[x];
quo += avrg[x];
x++; // put this here to see if it would make a difference.
}
cout << "Average = " << quo/a;
cin >> a; // just here to pause program in console window
}