this is insturction Write a program which prompts the user to enter up to 15 floating point numbers (terminated with a non-numeric), reads them into an array, then prints the following. The program must use an array (not a vector) to get credit. The array values in the original order, separated by commas, with no trailing comma at the last value. The array values where the order of each adjacent pair of elements is swapped, separated by commas (NOT every element swapped with its next neighbor, which would just move the first element to the end, but every original pair swapped only in that pair. For an odd element count, the last element should not change. See examples below.) The smallest number in the array. Example program outputs with user input shown in bold font: Enter up to 15 numbers, and a non-numeric to quit: 1 0 -1.001 # Original array: 1, 0, -1.001 The swapped array: 0, 1, -1.001 Smallest number: -1.001 Enter up to 15 numbers, and a non-numeric to quit: 1 0 -1.001 5 , Original array: 1, 0, -1.001, 5 The swapped array: 0, 1, 5, -1.001 Smallest number: -1.001 provide some comments for code and must done c++ I am getting errors and attached the picture. Could you check please and fix the error? thanks.  this code  #include using namespace std; int main() {  ,const,  const int maxSize = 15;     double numbers[maxSize];     int count = 0;     // Read input numbers until non-numeric input or reaching the maximum size of the array     while (count < maxSize && cin >> numbers[count]) {         count++;     }     cout << "Original array: ";     // Print the original array values separated by commas     for (int i = 0; i < count; i++) {         cout << numbers[i];         if (i < count - 1) {             cout << ", ";         }     }     cout << endl << "The swapped array: ";     // Print the array values where each adjacent pair of elements is swapped, except for the last element (if the count is odd)     for (int i = 0; i < count - 1; i += 2) {         cout << numbers[i + 1] << ", " << numbers[i];         if (i + 2 < count - 1) {             cout << ", ";         }     }     // Print the last element if the count is odd     if (count % 2 != 0) {         cout << ", " << numbers[count - 1];     }     // Find the smallest number in the array     double smallest = numbers[0];     for (int i = 1; i < count; i++) {         if (numbers[i] < smallest) {             smallest = numbers[i];         }     }     cout << endl << "Smallest number: " << smallest << endl;     return 0;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

this is insturction

Write a program which prompts the user to enter up to 15 floating point numbers (terminated with a non-numeric), reads them into an array, then prints the following. The program must use an array (not a vector) to get credit.

  • The array values in the original order, separated by commas, with no trailing comma at the last value.
  • The array values where the order of each adjacent pair of elements is swapped, separated by commas (NOT every element swapped with its next neighbor, which would just move the first element to the end, but every original pair swapped only in that pair. For an odd element count, the last element should not change. See examples below.)
  • The smallest number in the array.

Example program outputs with user input shown in bold font:

Enter up to 15 numbers, and a non-numeric to quit:

1 0 -1.001 #

Original array: 1, 0, -1.001 The swapped array: 0, 1, -1.001 Smallest number: -1.001 Enter up to 15 numbers, and a non-numeric to quit:

1 0 -1.001 5 ,

Original array: 1, 0, -1.001, 5 The swapped array: 0, 1, 5, -1.001 Smallest number: -1.001

provide some comments for code and must done c++

I am getting errors and attached the picture. Could you check please and fix the error? thanks. 

this code 

#include <iostream>
using namespace std;

int main() {
 ,const,  const int maxSize = 15;
    double numbers[maxSize];
    int count = 0;


    // Read input numbers until non-numeric input or reaching the maximum size of the array
    while (count < maxSize && cin >> numbers[count]) {
        count++;
    }

    cout << "Original array: ";

    // Print the original array values separated by commas
    for (int i = 0; i < count; i++) {
        cout << numbers[i];
        if (i < count - 1) {
            cout << ", ";
        }
    }

    cout << endl << "The swapped array: ";

    // Print the array values where each adjacent pair of elements is swapped, except for the last element (if the count is odd)
    for (int i = 0; i < count - 1; i += 2) {
        cout << numbers[i + 1] << ", " << numbers[i];
        if (i + 2 < count - 1) {
            cout << ", ";
        }
    }
    // Print the last element if the count is odd
    if (count % 2 != 0) {
        cout << ", " << numbers[count - 1];
    }

    // Find the smallest number in the array
    double smallest = numbers[0];
    for (int i = 1; i < count; i++) {
        if (numbers[i] < smallest) {
            smallest = numbers[i];
        }
    }

    cout << endl << "Smallest number: " << smallest << endl;

    return 0;

main.cpp:7:17: warning: extra tokens at end of #include directive
7 | #include<limits>;
I
main.cpp:12:17: warning: extra tokens at end of #include directive
12 | #include<limits>;
main.cpp: In function 'int main()':
main.cpp:11:3: error: expected primary-expression before ',' token
11 | ;,i++), {, cout,< <iostream>
|
main.cpp:11:4: error: 'i' was not declared in this scope
11 I ;,i++), {, cout,< <iostream>
main.cpp:58:1: error: expected '' at end of input
58 | }
|^
main.cpp:10:12: note: to match this '{'
10 int main() {
Transcribed Image Text:main.cpp:7:17: warning: extra tokens at end of #include directive 7 | #include<limits>; I main.cpp:12:17: warning: extra tokens at end of #include directive 12 | #include<limits>; main.cpp: In function 'int main()': main.cpp:11:3: error: expected primary-expression before ',' token 11 | ;,i++), {, cout,< <iostream> | main.cpp:11:4: error: 'i' was not declared in this scope 11 I ;,i++), {, cout,< <iostream> main.cpp:58:1: error: expected '' at end of input 58 | } |^ main.cpp:10:12: note: to match this '{' 10 int main() {
Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education