how to write the coding for this question? URGENT!!!

Insert a few integer numbers between -100 and 100. Determine and print how many negative numbers and how many positive numbers have been inserted. Insert the value 0 to stop inserting.
#include <iostream>
using namespace std;


int main()
{
int value = 0;
pValue = 0,
nValue = 0;

while(value!=0)
{
{
cout<<"Insert a few integer numbers between -100 and 100 OR ";
cout<<"Insert the value 0 to stop: ";
}
cin>>value;


if( value>=-100 && value<0)
nValue=nValue+1;

else if (value>0 && value<=100)
pValue=pValue+1;
}

cout<<"There are"<<nValue<<"negative integers"<<endl;
cout<<"There are"<<pValue<<"positive integers"<<endl;

if(value==0)
cout<<"Please enter intergers numbers between -100 and 100."<<endl;

return 0;

}


//any problem with this coding...i cant get the output that i wanted.

Last edited on
your code:
1
2
pValue = 0,
nValue = 0;

what did you foget here?
i have modified some of your code...but..still workkss..try it..
#include <iostream>
using namespace std;


int main()
{

int value = 0;
int pValue = 0;
int nValue = 0;

{
cout<<"Insert a few integer numbers between -100 and 100 OR ";
cout<<"Insert the value 0 to stop: ";
cin>>value;
}


while(value!=0)
{
if( value>=-100 && value<0)
nValue=nValue+1;

else if(value>0 && value<=100)
pValue=pValue+1;

cin>>value;
}

cout<<"There are"<<nValue<<"negative integers"<<endl;
cout<<"There are"<<pValue<<"positive integers"<<endl;

//if(value==0)
//cout<<"Please enter intergers numbers between -100 and 100."<<endl;

return 0;

}
thx..alot.
i solve the problem already.
Topic archived. No new replies allowed.