Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: None  |  size: 0.82 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int popu(int numberstore[], int userinp);
  6. void calc(int numberstore[], int userinp);
  7.  
  8. int main()
  9. {
  10.  
  11.   int userinp;
  12.   cout << "Number addition program." << endl << "Please enter the amount of numbers to add: ";
  13.   cin >> userinp;
  14.   int numberstore[userinp];
  15.  
  16.   popu(numberstore, userinp);
  17.   calc(numberstore, userinp);
  18.  
  19.   cin.get();
  20. }
  21.  
  22. int popu(int numberstore[], int userinp)
  23. {
  24.   int i;
  25.  
  26.   for(i = 0; i < userinp; i++)
  27.   {
  28.     cout << "Please enter integer " << (i+1) << ": ";
  29.     cin >> numberstore[i];
  30.   }
  31.    
  32. }
  33.  
  34. void calc( int numberstore[], int userinp)
  35. {
  36.   int i, calcer;
  37.  
  38.   calcer = 0;
  39.  
  40.   for(i = 0; i < userinp; i++)
  41.   {
  42.     calcer = calcer + numberstore[i];
  43.   }
  44.  
  45.   cout << "Total value of added numbers: " << calcer << endl;
  46.  
  47. }