InterviewSolution
Saved Bookmarks
| 1. |
Consider the following array declaration. Write statements to count how many numbers are greater than zero. int p[ ] = {-5, 6, -7, 0, 8, 9}; |
|
Answer» # include using namespace std; int main() { int p[]={-5, 6, -7, 0, 8, 9},i, count =0; for(i=5;i>=0;i--) if(p[i]>0) count++; cout<<"There are "<<count<<"numbers that are greater than zero"; } |
|