What does the above code segment do to the values of x and y

What does the above code segment do to the values of x and y? Consider the array called myArray declared below that contains positive and negative integers. 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, 10, 4, -23};

Solution

#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
   int myArray[]={-1,3,-9,9,33,-4,-5,10,4-23};//Array of integers
int poscount=0;//To hold count of +ve integers
   for (int i = 0; i < 10; ++i)
   {
       if(myArray[i]>0)
           poscount++;//increment count
   }
   cout<<\"Number of positive integers is \"<<poscount<<endl;
   return 0;
}

===================================

Output:

akshay@akshay-Inspiron-3537:~/Chegg$ g++ myArray.cpp
akshay@akshay-Inspiron-3537:~/Chegg$ ./a.out
Number of positive integers is 5

 What does the above code segment do to the values of x and y? Consider the array called myArray declared below that contains positive and negative integers. Wr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site