Ask Question
14 August, 14:34

Write a loop statement to count and display the number of positive integers in the array. That is, your loop should display the message "Number of positive integers is 5". int myArray[] = { - 1, 3, - 9, 9, 33, - 4, - 5, 100, 4, - 23};

+3
Answers (1)
  1. 14 August, 18:26
    0
    int count = 0;

    for (int i=0; i<10; i++)

    {

    if (myArray[i]>=0)

    {

    count++;

    }

    }

    cout<<"Number of positive integers is "<
    Explanation:

    The above written loop is for counting positive integers in the myArray[].

    For counting we have taken a count integer initialized with 0. On iterating over the array if the element is greater than or equal to 0 we consider it as positive and increasing the count. At the end printing the count.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a loop statement to count and display the number of positive integers in the array. That is, your loop should display the message ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers