PLEASE HELP!!!

Pages: 12
> Where do these numbers: -3.2, -0.5, 1.0, 2.3, 4.6, 6.2, 12.0, even come from?
> Are they just randomly chosen numbers for the purpose of your example?

Yes.


> We haven't covered arrays yet, so I shouldn't use them.
> However, I have one more class before the assignment is due

Good, you don't need arrays, and you have adequate time to work on your code.

The structure of your code would be:

1. Prompt for, and accept from the user the value x, entered via the keyboard (standard input)

2. Compute the value of ex; you can easily work out how to do that from the earlier posts in this thread.

3. Print out the result computed in step 2.

That's all that you are asked to do; arrays are not required at all.
Why doesn't this work:

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

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
	double test[6];
    const int N = sizeof(test) / sizeof( test[0] ) ;

	cout << "Please enter vaules for x: ";
	cin >> test;

    for( int i = 0 ; i < N ; ++i )
    {
        double x = test[i] ;

        double exp_x = 1 ;

        double term = 1 ;
        double previous_term = 1 ;

        for( int n = 1 ; term != 0 ; ++n )
        {
            term = previous_term * x / n ;
            exp_x += term ;
            previous_term = term ;
        }

        cout << fixed << setprecision(8) << setw(20) << exp_x << setw(20) << exp(x) << endl ;
    }
}


If gives me an error on line 13
Topic archived. No new replies allowed.
Pages: 12