Ask Question

Write a program to read 6 numbers and display the following counts: NPos: the number of posi; ve ones NNeg: the number of nega; ve ones NZero: the number of null ones

+3
Answers (1)
  1. 12 September, 17:39
    0
    Here you go. The program will count entered zeros. Null is not happening here ...

    int main ()

    {

    int NNeg = 0;

    int NPos = 0;

    int NZero = 0;

    std::cout << "Enter 6 numbers:/n";

    for (int i = 0; i < 6; i++) {

    double number;

    std::cin >> number;

    if (number < 0.0) NNeg++;

    else if (number > 0.0) NPos++;

    else NZero++;

    }

    std::cout << "You entered:/n";

    std::cout << NNeg << " negative numbers/n";

    std::cout << NZero << " times zero/n";

    std::cout << NPos << " positive numbers/n";

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a program to read 6 numbers and display the following counts: NPos: the number of posi; ve ones NNeg: the number of nega; ve ones ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers