fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a[10], i, n, c = 0;
  6.  
  7. cout << "Enter 10 numbers:\n";
  8. for (i = 0; i < 10; i++) {
  9. cin >> a[i];
  10. }
  11.  
  12. cout << "Enter the number to be searched: ";
  13. cin >> n;
  14.  
  15. for (i = 0; i < 10; i++) {
  16. if (n == a[i]) {
  17. cout << "\nNumber " << n << " found at position " << i + 1 << endl;
  18. c = 1;
  19. }
  20. }
  21.  
  22. if (c == 0) {
  23. cout << "\nNumber " << n << " is not found." << endl;
  24. }
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
Enter 10 numbers:
Enter the number to be searched: 
Number 21897 found at position 8