Answer to Question #11282 in C# for ajay

Question #11282
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.
1
Expert's answer
2012-07-05T07:29:00-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS