How to Create a program in C that accepts a set of integers and finds the number of positive and negative numbers.And the program stops when the user enters 0 for the integer value.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int arrayofnumbers[100];
int number=0;
cin>>number;
int count=0;
while(number!=0){
arrayofnumbers[count]=number;
count++;
cin>>number;
}
cout<<"Positive numbers: ";
for(int i=0;i<count;i++){
if(arrayofnumbers[i]>0){
cout<<arrayofnumbers[i]<<" ";
}
}
cout<<"
Negative numbers: ";
for(int i=0;i<count;i++){
if(arrayofnumbers[i]<0){
cout<<arrayofnumbers[i]<<" ";
}
}
cin>>number;
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C#