Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main (void)
- {
- float pro_of_neg = 1.0, val;
- int neg_qty = 0, zero_qty = 0;
- cout << "enter a value or ctrl+z to end: ";
- cin >> val;
- while (!cin.eof())
- {
- if (val == 0.0)
- zero_qty++;
- if (val < 0.0)
- {
- neg_qty++;
- pro_of_neg *= val;
- }
- cout << "enter a value or ctrl+z to end: ";
- cin >> val;
- }
- if (neg_qty > 1)
- cout << "\nproduct of negative elements: " << pro_of_neg << endl;
- else
- cout << "\nare no negative elements or too few values!" << endl;
- if (zero_qty > 0)
- cout << "\nquantity of zero elements: " << zero_qty << endl;
- else
- cout << "\nare no zero elements!" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement