/*
Name: Sean Griffin
Date: October 31, 2006
Description: Write code that will take numbers in from the user, add
the numbers together, report the sum, and then report
the numbers in reverse order.
Design code that will recieve from the user a set of
seven numbers. These numbers will then be added and
the result will be provided.
The code will return the set in reverse order after
providing the sum of each element.
*/
#include <iostream>
#define array_size 7
float array_add(float *);
void init_array(float *);
void disp_r_array(float *);
void main(void)
{
float input[array_size];
init_array(input);
array_add(input);
disp_r_array(input);
char c1;
std::cin >> c1;
}
float array_add(float *x)
{
float total=0;
for(int i=0; i<array_size; i++)
total+=(*x+i);
std::cout << "The sum of the numbers you provided is: ";
std::cout << total << std::endl;
}
void init_array(float *x)
{
std::cout << "You will be asked to input seven numbers" << std::endl;
for(int i=0; i<array_size; i++)
{
std::cout << "Please input a number: ";
std::cin >> *x;
*x++;
}
std::cout << std::endl;
}
void disp_r_array(float *x)
{
std::cout << "The numbers you provided in reverse order are:";
std::cout << std::endl;
for(int i=0; i<array_size; i++)
*x++;
for(int i=0; i<array_size; i++)
{
std::cout << *x << ", ";
*x--;
}
}