-
August 17th, 2012, 07:51 AM
#1
enerting double values into a array
hey guys,
i have been struggling for hours now on how to enter double values into my array so that it can output the sum of the numbers less than 24. this is my code so far. and im stuck
#include <iostream>
using namespace std;
int main()
{
double positive_values[10];
double[] positive_values = {2, 57, -4, 7, 19, 23, 3, 9, 15, 44};
double sum = 0;
}
-
August 17th, 2012, 08:15 AM
#2
Re: enerting double values into a array
double positive_values[] = {2, 57, -4, 7, 19, 23, 3, 9, 15, 44};
-
August 17th, 2012, 08:44 AM
#3
Re: enerting double values into a array
i ran the program and its telling me der are too many initializers
-
August 17th, 2012, 11:58 AM
#4
Re: enerting double values into a array
Then you didn't follow GCDEF's example. Cut & paste the example into your code overwriting your old code.
-
August 20th, 2012, 02:32 AM
#5
Re: enerting double values into a array
You have two choices:
Code:
double positive_values[10];
positive_values[0] = 2;
positive_values[1] = 57;
...
positive_values[9] = 44;
or
Code:
double positive_values[] = {2, 57, -4, 7, 19, 23, 3, 9, 15, 44};
Be careful where you put the brackets []. It's not after the type (like in C#), but after the variable.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|