Advertisement
Donald_Fortier

Untitled

May 27th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool isSorted(int number[], int SIZE);/* You're defining a prototype here, so no variable names */
  5.  
  6. int main()
  7. {
  8.     cout << " Enter list: ";
  9.     int SIZE;/* only const are ALL_CAPS */
  10.     cin >> SIZE;
  11.     const int A = SIZE;/* Why redefine size as A instead of just using size? */
  12.     int number[A];
  13.  
  14.     for (int i = 0; i < SIZE; i++)
  15.     {
  16.         cin >> number[i];
  17.     }
  18.  
  19.     if (isSorted)
  20.         cout << " The list is already sorted \n" << endl;
  21.     else
  22.         cout << " The list is not sorted \n" << endl;
  23.  
  24.     return 0;
  25. }
  26.  
  27. bool isSorted(int number[], int SIZE)
  28. {
  29.     for (int i = 0; i < SIZE; i++)
  30.     {
  31.         if (number[i] > number[i + 1])
  32.             return false;
  33.     }
  34.  /* What if it is sorted?  Where do you return true in that case? */
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement