- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
In the program below, we've aked user to enter 10 numbers to check for number of positive number, negative number and zero occurrence in C++
Source Code: Print Count of number of positive,negative and zero in given Numbers
/* C++ Program - Count Occurrence of positive,negative and zero in given Numbers */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int nop=0, non=0, noz=0, arr[10], i; cout<<"Enter 10 numbers : "; for(i=0; i<10; i++) { cin>>arr[i]; } for(i=0; i<10; i++) { if(arr[i]<0) { non++; } else if(arr[i]==0) { noz++; } else { nop++; } } cout<<"Positive Numbers = "<<nop<<"\n"; cout<<"Negative Numbers = "<<non<<"\n"; cout<<"Zero = "<<noz<<"\n"; getch(); }Output
Enter 10 numbers: 2 3 -3 -4 -5 0 0 0 1 3 Positive Numbers =4 Negative Numbers =3 Zero =3