fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int tab[4] = {0, 1, 4, 99};
  5.  
  6. bool isInArray(int num) {
  7. for (int i = 0; i < 5; i++) {
  8. if (tab[i] == num) {
  9. return true;
  10. }
  11. }
  12. return false;
  13. }
  14.  
  15. int main() {
  16. for (int i = 0; i <= 5; i++) {
  17. if (isInArray(i)) {
  18. cout << i << " is in array!\n";
  19. } else {
  20. cout << i << " is not in array!\n";
  21. }
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
0 is in array!
1 is in array!
2 is in array!
3 is in array!
4 is in array!
5 is in array!