Question

int myarray[100]; cout << "Enter number of integers : "; int n; cin >> n; cout...

int myarray[100];
cout << "Enter number of integers : ";
int n;
cin >> n;
cout << "Enter " << n << " integers" << endl;
for (int i = 0; i < n; i++)
  cin >> myarray[i];
cout << "Contents of array : ";
printArray(myarray, n);

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

void printArray(int myarray[], int n) {
    for(int i = 0; i < n; ++i) {
        cout << myarray[i] << " ";
    }
    cout << endl;
}

int main() {
    int myarray[100];
    cout << "Enter number of integers : ";
    int n;
    cin >> n;
    cout << "Enter " << n << " integers" << endl;
    for (int i = 0; i < n; i++)
      cin >> myarray[i];
    cout << "Contents of array : ";
    printArray(myarray, n);
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
int myarray[100]; cout << "Enter number of integers : "; int n; cin >> n; cout...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #include <iostream>#include <string>using namespace std;// Implement printArray here// Implement deleteSmallest here//...

    #include#includeusing namespace std;// Implement printArray here// Implement deleteSmallest here// DO NOT CHANGE MAIN FUNCTION BELOWint main() {int myarray[100];cout << "Enter number of integers : ";int n;cin >> n;cout << "Enter " << n << " integers" << endl;for (int i = 0; i < n; i++)cin >> myarray[i];cout << "Contents of array : ";printArray(myarray, n);deleteSmallest(myarray, n);cout << "Contents of array after deleteSmallest: ";printArray(myarray, n-1);}

  • #include <iostream> #include <string> using std::string; using std::cout; using std::endl; void testAnswer(string testname, int answer, int...

    #include <iostream> #include <string> using std::string; using std::cout; using std::endl; void testAnswer(string testname, int answer, int expected) { if (answer == expected) cout << "PASSED: " << testname << " expected and returned " << answer << "\n"; else cout << "FAILED: " << testname << " returned " << answer << " but expected " << expected << "\n"; } // Implement printArray here void printArray(int array[],int b) { for(int i = 0; i<b;i++) { std::cout<< array[i] << "...

  • //Find two smallest integers #include <iostream> #include <string> using namespace std; // implement printArray here //...

    //Find two smallest integers #include <iostream> #include <string> using namespace std; // implement printArray here // implement findTwoSmallest here // DO NOT WRITE ANY CODE BELOW THIS LINE (EXCEPT FOR TESTING - REMOVE BEFORE SUBMITTING) int main() {     int n;     int arr[100];        cout << "Enter number of integers: ";     cin >> n;        cout << "Enter " << n << " integers: ";       for(int i = 0; i < n; i++) {        ...

  • #include <iostream> using namespace std; int main(void) {    int SIZE;    cout<<"Enter the size of the...

    #include <iostream> using namespace std; int main(void) {    int SIZE;    cout<<"Enter the size of the array"<<endl;    cin>>SIZE;     int *numlist = new int[SIZE];     // Read SIZE integers from the keyboard     for (int i = 0; i<SIZE; i++ )    {        cout << "Enter value #" << i+1 << ": ";        cin >> numlist[i];     }     // Display the numbers in a reverse order     for (int i = SIZE; i > 0; i--...

  • #include <iostream> using namespace std; template <typename Item> class MyArray{ private:    Item *myarray;    int...

    #include <iostream> using namespace std; template <typename Item> class MyArray{ private:    Item *myarray;    int size;    int used;    void doubleSize(); public:    MyArray();    ~MyArray();    int length();    void insertHead(Item i);    void insertTail(Item i);    void deleteHead();    void deleteTail();    void sortAscending();    void sortDescending();    Item operator [](int i){        return myarray[i];    } }; template <typename Item> MyArray<Item>::MyArray(){    size = 5;    used = 0;    myarray = new Item[size];...

  • int num; int total = 0; cout << "Enter a number from 1 to 10."; cin...

    int num; int total = 0; cout << "Enter a number from 1 to 10."; cin >> num; switch (num) {    case 1:    case 2:   total = 5;    case 3:   total = 10;    case 4:   total = total + 3;    case 8:   total = total + 6;    default: total = total + 4; } cout << total; A. 10 B. 0 C. 23 D. 3 E. None of these

  • Who could write the array.cpp file ?   //main.cpp #include "array.hpp" #include <iostream> int main() { int...

    Who could write the array.cpp file ?   //main.cpp #include "array.hpp" #include <iostream> int main() { int n; std::cin >> n; array a(n); for (int i = 0; i < n; i++) { std::cin >> a.data()[i]; } std::cout << "array size:" << a.max_size() << std::endl; std::cout << "array front:" << a.front() << std::endl; std::cout << "array back:" << a.back() << std::endl; int* data = a.data(); std::cout << "array elements using data:" << std::endl; for (int i = 0; i < n;...

  • #include <iostream> using namespace std; int main() {    int i,n;    int counter=0;    cin...

    #include <iostream> using namespace std; int main() {    int i,n;    int counter=0;    cin >> n;    for (i = 1; i <= n; i++)    {        if (n % i == 0 )        {            counter++;        }        /*else        {            counter++;            i++;        }*/           }    if (counter == 2)        cout << n <<...

  • /* Array expander: Write a function that accepts an int array as argument. The function should...

    /* Array expander: Write a function that accepts an int array as argument. The function should create a new array that is n times the size of the argument array, where n is a user input. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. The function should return a pointer to the new array */ #include <iostream> using namespace std; const int NUM_ELEM...

  • #include <iostream> uisng  namespace std; int main() {             cout<<"Enter your three test scores and I...

    #include <iostream> uisng  namespace std; int main() {             cout<<"Enter your three test scores and I will ";                  <<" average them: ";             int score1, score2, score3,             cin>>score1>>score2>>score3;             double average;             average = (score1 + score2 + score3) / 3.0;             if (average = 100);                         perfectScore = true; // set the flag variable             cout<<"Your average is "<<average <<endl;             bool perfectScore;             if (perfectScore);             {                         cout<<"Congratulations!\n";                         cout<<"That's a perfect score.\n";                        ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT