Advertisement
HakdogForce

LABORATORY EXERCISE 1 - 01 ONE DIMENTIONAL ARRAY

Dec 3rd, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. /*  ONE-DIMENSIONAL ARRAY
  2.     Porquillo, Aljan A.
  3. */
  4.  
  5.  
  6. #include <iostream>
  7. using namespace std;
  8.  
  9. int num[20], numcount = 1, x;
  10.  
  11. int main(){
  12.    
  13.     cout << "THIS CODE IS TO REVERSE A 20 DIGIT NUMBER" << endl;
  14.    
  15.     for(int i = 1; i <= 20; i++){
  16.         cout << "Enter number " << " #" << numcount++ << ": ";
  17.         cin >> num[i];
  18.     }
  19.    
  20.     for(x = 20; x >= 0; x--){
  21.         if(num[x] == 0){
  22.             continue;
  23.         }
  24.         cout << num[x];
  25.     }
  26.    
  27. }
  28.  
  29. /*  PSEUDO CODE:
  30. set array num with the buffer size of 20
  31. set varible numcount to use in looping numbers
  32. set variable x
  33.  
  34. display title and the purpose of the program
  35.  
  36. loop through each number then put
  37. in the array declared until it gets 20
  38. end loop
  39.  
  40. loop variable x
  41. decrement until it gets 0
  42. if array has 0 and its true
  43. ignore (continue)
  44.  
  45. display the array called num
  46.  
  47. end program
  48. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement