Answer:
#include <iostream>
using namespace std;
int main()
{
int arr[]={3,-9,9,33,-4,-5, 100,4,-23};
int pos;
int n=sizeof(arr)/sizeof(arr[0]);
for(int i=0;i<n;i++){
if(arr[i]>=0){
pos++;
}
}
cout<<"Number of positive integers is "<<pos<<endl;
return 0;
}
Explanation:
create the main function in the c++ programming and declare the array with the element. Then, store the size of array by using the formula:
int n=sizeof(arr)/sizeof(arr[0]);
after that, take a for loop for traversing the array and then check condition for positive element using if statement,
condition is array element greater than or equal to zero.
if condition true then increment the count by 1.
this process happen until the condition true
and finally print the count.