fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. // simple array printing method 1
  5. int arr[3] = {1,2,3};
  6. cout << arr[0] << endl;
  7. cout << arr[1] << endl;
  8. cout << arr[2] << endl;
  9. cout << arr[3] << "garbage value" << endl;
  10.  
  11. // simple array printing method 2
  12. cout << "\n";
  13. int arr1[3];
  14. arr1[0] = 3;
  15. arr1[1]= 5;
  16. arr1[2] = 66;
  17. arr1[3] = 32;
  18. cout << arr1[0] << " " << arr1[1] << " " << arr1[2] << " " << arr1[3] << endl;
  19.  
  20. // simple array input and printing them using for loop
  21. cout << "\n";
  22. int arr2[5];
  23. for (int i = 0; i < 5 ; i++){
  24. cin >> arr2[i];
  25. }
  26. cout << arr2[5];
  27. for (int i = 0; i < 5; i++){
  28. cout << arr2[i];
  29. cout << "\n";
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. return 0;
  38.  
  39. }
  40.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
1
2
3
0garbage value

3 5 66 32

220561897933600
5298
0
0
-1817181232