Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // Print the non-zero elements of an array.
- int main()
- {
- // Create a list of numbers.
- int numbers[]{ 1, 0, 3, 4, 0, 6, 7, 8, 9};
- // Check each number.
- for (int n : numbers)
- {
- // If the number is not zero,
- if (n != 0)
- {
- // Display the number.
- cout << n << ' ';
- }
- }
- // Put the cursor on the next line.
- cout << endl;
- // End the program.
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement