BlackWolfy

Count the number of zeros (using a dynamic array)

Feb 10th, 2023
1,205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int m, counter=0;
  6.     cout << "How many numbers will you check: "<<endl;
  7.     cin >> m;
  8.     int* U;
  9.     U = new int[m];
  10.     for (int i = 0; i < m; i++) {
  11.         cout << "Enter an element: "<<endl;
  12.         cin >> U[m];
  13.         if (U[m] == 0) {
  14.             counter++;
  15.         }
  16.     }
  17.     cout << "The number of 0-s in this array is: "<<counter;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment