# expected

***

**1. Checking For Predefined Values**

```cpp
#include <iostream>
#include <optional>

using namespace std;

int main() {
  optional<int> number = 10;

  if (number.has_value()) {
    cout << "The value of the number is: " << *number << endl;
  } else {
    cout << "The number is not set" << endl;
  }

  return 0;
}
```

**2. Checking For Null Pointers**

```cpp
#include <iostream>

using namespace std;

class MyClass {
public:
  MyClass() : ptr(nullptr) {}

  void setPtr(int* ptr) { this->ptr = ptr; }

  int* getPtr() { return ptr; }

private:
  int* ptr;
};

int main() {
  MyClass myClass;

  if (myClass.getPtr() != nullptr) {
    cout << "The pointer is not null" << endl;
  } else {
    cout << "The pointer is null" << endl;
  }

  return 0;
}
```

**3. Checking For Empty Collections**

```cpp
#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> numbers;

  if (numbers.empty()) {
    cout << "The vector is empty" << endl;
  } else {
    cout << "The vector is not empty" << endl;
  }

  return 0;
}
```

**4. Checking For Errors**

```cpp
#include <iostream>
#include <exception>

using namespace std;

int divide(int a, int b) {
  if (b == 0) {
    throw invalid_argument("Division by zero");
  }

  return a / b;
}

int main() {
  try {
    int result = divide(10, 2);
    cout << "The result is: " << result << endl;
  } catch (exception& e) {
    cout << "An error occurred: " << e.what() << endl;
  }

  return 0;
}
```

**5. Ensuring Function Arguments Are Valid**

```cpp
#include <iostream>

using namespace std;

bool isPositive(int number) {
  return number > 0;
}

int main() {
  int number = -1;

  if (number >= 0) {
    cout << "The number is positive" << endl;
  } else {
    cout << "The number is negative" << endl;
  }

  return 0;
}
```

**6. Checking For User Input**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number;

  cout << "Enter a number: ";
  cin >> number;

  if (number != 0) {
    cout << "The number is not zero" << endl;
  } else {
    cout << "The number is zero" << endl;
  }

  return 0;
}
```

**7. Checking For File Existence**

```cpp
#include <iostream>
#include <fstream>

using namespace std;

int main() {
  ifstream file("myfile.txt");

  if (file.is_open()) {
    cout << "The file is open" << endl;
  } else {
    cout << "The file is not open" << endl;
  }

  return 0;
}
```

**8. Checking For Object Validity**

```cpp
#include <iostream>

using namespace std;

class MyClass {
public:
  MyClass() : valid(true) {}

  void invalidate() { valid = false; }

  bool isValid() { return valid; }

private:
  bool valid;
};

int main() {
  MyClass myClass;

  if (myClass.isValid()) {
    cout << "The object is valid" << endl;
  } else {
    cout << "The object is not valid" << endl;
  }

  return 0;
}
```

**9. Checking For Type Compatibility**

```cpp
#include <iostream>
#include <typeinfo>

using namespace std;

int main() {
  int number = 10;

  if (typeid(number) == typeid(int)) {
    cout << "The variable 'number' is of type int" << endl;
  } else {
    cout << "The variable 'number' is not of type int" << endl;
  }

  return 0;
}
```

**10. Checking For Equality**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number1 = 10;
  int number2 = 10;

  if (number1 == number2) {
    cout << "The numbers are equal" << endl;
  } else {
    cout << "The numbers are not equal" << endl;
  }

  return 0;
}
```

**11. Checking For Inequality**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number1 = 10;
  int number2 = 20;

  if (number1 != number2) {
    cout << "The numbers are not equal" << endl;
  } else {
    cout << "The numbers are equal" << endl;
  }

  return 0;
}
```

**12. Checking For Greater Than**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number1 = 10;
  int number2 = 20;

  if (number1 > number2) {
    cout << "The first number is greater than the second number" << endl;
  } else {
    cout << "The first number is not greater than the second number" << endl;
  }

  return 0;
}
```

**13. Checking For Greater Than or Equal To**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number1 = 10;
  int number2 = 10;

  if (number1 >= number2) {
    cout << "The first number is greater than or equal to the second number" << endl;
  } else {
    cout << "The first number is not greater than or equal to the second number" << endl;
  }

  return 0;
}
```

**14. Checking For Less Than**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number1 = 10;
  int number2 = 20;

  if (number1 < number2) {
    cout << "The first number is less than the second number" << endl;
  } else {
    cout << "The first number is not less than the second number" << endl;
  }

  return 0;
}
```

**15. Checking For Less Than or Equal To**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number1 = 10;
  int number2 = 10;

  if (number1 <= number2) {
    cout << "The first number is less than or equal to the second number" << endl;
  } else {
    cout << "The first number is not less than or equal to the second number" << endl;
  }

  return 0;
}
```

**16. Checking For Logical AND**

```cpp
#include <iostream>

using namespace std;

int main() {
  bool condition1 = true;
  bool condition2 = true;

  if (condition1 && condition2) {
    cout << "Both conditions are true" << endl;
  } else {
    cout << "At least one condition is false" << endl;
  }

  return 0;
}
```

**17. Checking For Logical OR**

```cpp
#include <iostream>

using namespace std;

int main() {
  bool condition1 = false;
  bool condition2 = true;

  if (condition1 || condition2) {
    cout << "At least one condition is true" << endl;
  } else {
    cout << "Both conditions are false" << endl;
  }

  return 0;
}
```

**18. Checking For Logical NOT**

```cpp
#include <iostream>

using namespace std;

int main() {
  bool condition = false;

  if (!condition) {
    cout << "The condition is false" << endl;
  } else {
    cout << "The condition is true" << endl;
  }

  return 0;
}
```

**19. Checking For Range**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number = 10;

  if (number >= 0 && number <= 100) {
    cout << "The number is between 0 and 100" << endl;
  } else {
    cout << "The number is not between 0 and 100" << endl;
  }

  return 0;
}
```

**20. Checking For Multiple Conditions**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number1 = 10;
  int number2 = 20;
  bool condition = true;

  if (number1 > 0 && number2 > 0 && condition) {
    cout << "All conditions are true" << endl;
  } else {
    cout << "At least one condition is false" << endl;
  }

  return 0;
}
```

**21. Checking For Nested Conditions**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number = 10;

  if (number > 0) {
    if (number < 100) {
      cout << "The number is between 0 and 100" << endl;
    } else {
      cout << "The number is greater than 100" << endl;
    }
  } else {
    cout << "The number is negative" << endl;
  }

  return 0;
}
```

**22. Checking For Conditional Statements**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number = 10;

  switch (number) {
    case 0:
      cout << "The number is zero" << endl;
      break;
    case 1:
      cout << "The number is one" << endl;
      break;
    default:
      cout << "The number is not zero or one" << endl;
      break;
  }

  return 0;
}
```

**23. Checking For Default Conditional Statements**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number = 10;

  switch (number) {
    case 0:
    case 1:
      cout << "The number is zero or one" << endl;
      break;
    default:
      cout << "The number is not zero or one" << endl;
      break;
  }

  return 0;
}
```

**24. Checking For Conditional Loops**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number = 10;

  while (number > 0) {
    cout << "The number is greater than zero" << endl;
    number--;
  }

  return 0;
}
```

**25. Checking For Do-While Loops**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number = 10;

  do {
    cout << "The number is greater than or equal to zero" << endl;
    number--;
  } while (number >= 0);

  return 0;
}
```

**26. Checking For For Loops**

```cpp
#include <iostream>

using namespace std;

int main() {
  for (int number = 0; number < 10; number++) {
    cout << "The number is less than ten" << endl;
  }

  return 0;
}
```

**27. Checking For Range-Based For Loops**

```cpp
#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> numbers = {1, 2, 3, 4, 5};

  for (int number : numbers) {
    cout << "The number is: " << number << endl;
  }

  return 0;
}
```

**28. Checking For Ternary Conditional Operator**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number = 10;
  string result = (number > 0) ? "Positive" : "Non-Positive";
  cout << "The number is: " << result << endl;

  return 0;
}
```

**29. Checking For Lambda Expressions**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number = 10;
  auto isPositive = [](int number) { return number > 0; };

  if (isPositive(number)) {
    cout << "The number is positive" << endl;
  } else {
    cout << "The number is not positive" << endl;
  }

  return 0;
}
```

**30. Checking For Function Pointers**

```cpp
#include <iostream>

using namespace std;

int add(int a, int b) { return a + b; }

int main() {
  int (*sum)(int, int) = add;
  int result = sum(10, 20);
  cout << "The result is: " << result << endl;

  return 0;
}
```

**31. Checking For Class Methods**

```cpp
#include <iostream>

using namespace std;

class MyClass {
public:
  MyClass() : number(0) {}

  void setNumber(int number) { this->number = number; }

  int getNumber() { return number; }

private:
  int number;
};

int main() {
  MyClass myClass;
  myClass.setNumber(10);
  int number = myClass.getNumber();
  cout << "The number is: " << number << endl;

  return 0;
}
```

**32. Checking For Object Pointers**

```cpp
#include <iostream>

using namespace std;

class MyClass {
public:
  MyClass() : number(0) {}

  void setNumber(int number) { this->number = number; }

  int getNumber() { return number; }

private:
  int number;
};

int main() {
  MyClass* myClass = new MyClass();
  myClass->setNumber(10);
  int number = myClass->getNumber();
  cout << "The number is: " << number << endl;
  delete myClass;

  return 0;
}
```

**33. Checking For Arrays**

```cpp
#include <iostream>

using namespace std;

int main() {
  int numbers[] = {1, 2, 3, 4, 5};
  for (int number : numbers) {
    cout << "The number is: " << number << endl;
  }

  return 0;
}
```

**34. Checking For Pointers**

```cpp
#include <iostream>

using namespace std;

int main() {
  int* number = new int(10);
  cout << "The number is: " << *number << endl;
  delete number;

  return 0;
}
```

**35. Checking For References**

```cpp
#include <iostream>

using namespace std;

int main() {
  int number = 10;
  int& reference = number;
  cout << "The number is: " << reference << endl;
  reference++;
  cout << "The number is now: " << number << endl;

  return 0;
}
```

**36. Checking For Const Variables**

```cpp
#include <iostream>

using namespace std;

int main() {
  const int number = 10;
  cout << "The number is: " << number << endl;
  // number++; // Error: cannot modify a const variable

  return 0;
}
```

**37. Checking For Immutable Objects**

```cpp
#include <iostream>

using namespace std;

class MyClass {
public:
  MyClass(int number) : number(number) {}

  int getNumber() const { return number; }

private:
  int number;
};

int main() {
  const MyClass myClass(10);
  cout << "The number is: " << myClass.getNumber() << endl;
  // myClass.setNumber(20); // Error: cannot modify an immutable object

  return 0;
}
```

**38. Checking For Type Aliases**

```cpp
#include <iostream>

using namespace std;

using Number = int;

int main() {
  Number number = 10;
  cout << "The number is: " << number << endl;

  return 0;
}
```

**39. Checking For Templates**
