fork download
  1. float x;
  2. int an;
  3.  
  4. cout << "a[n]: ";
  5. cin >> an;
  6.  
  7. float *a = new float[an];
  8.  
  9. for (int i = 0; i < an; i++) {
  10. cout << "a[" << i+1 << "]" << ": ";
  11. cin >> a[i];
  12. }
  13.  
  14. cout << "x: ";
  15. cin >> x;
  16.  
  17. for (int i = 0; i < an - 1; i+=2) {
  18. if ((x >= a[i]) && (x < a[i+1])) {
  19. cout << a[i] << " <= " << x << " < " << a[i+1] << "\n";
  20. }
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:5: error: ‘cout’ does not name a type
     cout << "a[n]: ";
     ^
prog.cpp:5:5: error: ‘cin’ does not name a type
     cin >> an;
     ^
prog.cpp:9:5: error: expected unqualified-id before ‘for’
     for (int i = 0; i < an; i++) {
     ^
prog.cpp:9:21: error: ‘i’ does not name a type
     for (int i = 0; i < an; i++) {
                     ^
prog.cpp:9:29: error: ‘i’ does not name a type
     for (int i = 0; i < an; i++) {
                             ^
prog.cpp:14:5: error: ‘cout’ does not name a type
     cout << "x: ";
     ^
prog.cpp:15:5: error: ‘cin’ does not name a type
     cin >> x;
     ^
prog.cpp:17:5: error: expected unqualified-id before ‘for’
     for (int i = 0; i < an - 1; i+=2) {
     ^
prog.cpp:17:21: error: ‘i’ does not name a type
     for (int i = 0; i < an - 1; i+=2) {
                     ^
prog.cpp:17:33: error: ‘i’ does not name a type
     for (int i = 0; i < an - 1; i+=2) {
                                 ^
stdout
Standard output is empty