#include <iostream>
using namespace std;
int main()
{
int z=0, x=0, c=0;
float res=0, a[9]={0,0,0,0,0,0,0,0,0};
cout << "How many numbers do you want to divide: " << endl;
cin >> z;
for (x=0;x<z;x++)
{
c = x + 1;
cout << "Enter the " << c << " number: " << endl;
cin >> a[x];
}
for(x;x>0;x--)
{
res = a[x]/a[x-1];
cout << a[x] << "\n";
}
cout << "Result = " << res << endl << "\n";
return 0;
}
I am trying to get the user to input as many numbers as they want and divide those numbers, for example 8/2/2=2, but the result for a[0] is always 0 and I am not sure how to get the math right, all I could find is for dividing two numbers only, excuse my lack of knowledge I am new to this.
expected :
how many numbers do you want to divide:
3
enter the 1 number:
8
enter the 2 number:
2
enter the 3 number:
2
8
2
2
result = 2