CSE 1222 u2013 quiz10 - CSE 1222 quiz10#include...

This preview shows page 1 - 3 out of 3 pages.

CSE 1222 – quiz10#include <cstdlib>#include <iostream>using namespace std;// FUNCTION PROTOTYPESvoid get_list(int list[], int size);int count_pos(const int list[], int size);int count_zeros(const int list[], int size);int main(){int length;int num_pos, num_zeros;int * list;// Prompt and read number of elements from the user into the variable lengthcout << "Enter number of elements: ";cin >> length;// Create a new array (dynamically allocate) of size length and assign it to variable listlist = new int[length];// Prompt and read the elements from the user. Call the function get_listget_list( list, length);// Count the number of positive numbers in the list. Call the function count_pos. Use variable num_posint count_pos( num_pos);// Count the number of zeros in the list. Call the function count_zeros. Use variable num_zerosint count_zeros(num_zeros);// Display number of positive elementscout << "Number of positive elements: " << num_pos << endl;// Display number of zeroscout << "Num of zero elements: " << num_zeros << endl;
// De-allocate the listdelete[]list;return 0;}

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture