Nov 21, 2011 at 1:27am UTC
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.
Nov 21, 2011 at 8:31am UTC
#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 Nov 21, 2011 at 8:38am UTC
Nov 21, 2011 at 8:58am UTC
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;
}
Nov 21, 2011 at 9:45am UTC
thx..alot.
i solve the problem already.