I am very new to C++, and am struggling with these problems. I must enter in a 10 integer array, and then reverse the array. I do not want to make a function, or use characters, just simple code, this is what I thinking is along the lines of the answer

#include <iostream>
using namespace std;

int main (){
    int SourceArray[10]; // this will be the original array
    int DestArray[10];    // this will be the array that the reverse goes into
    int i;
    cout << "Enter a 10 Integer array with Positive Integers" << endl;
        for(int i=0; i<10; i++){
            cin >> SourceArray[i];
    cout << "Your reversed array is: " << endl;
        for(int i=10; i >=0; i--){
                  cin >> SourceArray[i];
                  SourceArray[i] = DestArray[i];

i know this has many mistakes, but I just cannot figure out arrays, I am having a terrible time figuring them out. But i want it to be as simple as above, with no other libraries etc...

Question 2.
I must make a 10 floating point array (similar to above) and show the positive integers, negative integers, max and min, sum, and sum of absolute values. Any way to get me started on this? Oh, and i'm suppose to have them shown in a fixed format with 2 decimals, and the results for average, sum, and other sum are suppose to be in scientific...Any help would be appreciated, I have searched the forums and internet with no simple answer. THANKS A TON!!

8 Years
Discussion Span
Last Post by nezumi4

ok, one very noticeable mistake is when you are trying to reverse your array you put
cin>> SourceArray;
This is pretty much asking the user to re-enter on the SourceArray[] and will overwrite the first one entered. To have decimals, you must #include <iomanip> and use the 'showpoint' and 'setprecision' commands. You can use doubles or floats.
I know how you feel, i'm somewhat new to this too.


I actually figured out the first program...ha ha, after all that bitching lol. However, the 2nd problem is the toughest, and i will not have time to work on it till tommarow...so thanks for you help


i would recommend that you have different functions for what you need to do. For your sum i would recommend a for loop that will have

int sum=0;
for(int i=0;i<10;i++){

(i is for index) or something simple like that. The average shouldnt be hard either, just copy the sum (if you want) and divide it by 10 (since ten is the total in the array). For printing the positive and the negative numbers, there is actually and easy and a hard way. Hard way you can make a new array and store in the array the numbers that are positive/negative and then print them out. Easy way is


for (int i=0;i<10;i++){
cout<<SourceArray<<", ";


for (int i=0;i<10;i++){
cout<<SourceArray<<", ";

For the max and min i would use a for loop and have a temp variable to hold the max/min number while it checks the next one to see if it is greater or not. For the absolute value you should use the abs operation which you must #include <cmath> (im not sure i dont have my book with me). Good Luck

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.