reellearning

Intro to Arrays in C++

Jun 26th, 2012
3,910
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. /*
  2.  * arrays.cpp
  3.  *
  4.  *  Created on: Jun 25, 2012
  5.  *      Author: Derek
  6.  */
  7.  
  8.  
  9. #include <iostream>
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14.  
  15.     double rainfall[5];
  16.  
  17.     rainfall[0] = 2.3;
  18.     rainfall[1] = 0.3;
  19.     rainfall[2] = 0.0;
  20.     rainfall[3] = 4.1;
  21.     rainfall[4] = 0.5;
  22.  
  23.     for(int i = 0; i < 5; i++)
  24.     {
  25.         cout << rainfall[i] << endl;
  26.     }
  27.  
  28.     for(int i = 0; i < 5; i++)
  29.     {
  30.         cout << "Enter a rainfall amount: " << endl;
  31.         cin >> rainfall[i];
  32.     }
  33.  
  34.     for(int i = 0; i < 5; i++)
  35.     {
  36.         cout << rainfall[i] << endl;
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment