I am doing simple program in C++ where I get three kinds of answers - positive, negative and zero. Which operator should I use to get in the end this type of answer:
There are ... zeros.
There are ... positives.
There are ... negatives.
I need help with c++/question about operator.?
To write an absolutely simple program, use the following code.
int main()
{
int iZero = 0;
int iPositive =0;
int iNegative =0;
//Now write the code to check the input and increment that particular integer, eg.
if(iInput == 0)
{
iZero++;
}
else if (iInput %26gt; 0)
{
iPositive++;
}
else if (iInput %26lt; 0)
{
iNegative++;
}
}
//In the end you can check all the iZero, iPositive and iNegative Values.
//You can use an else instead of else if here.
//Also you can use switch case statements, but then there are endless solutions to your question.
}
floral deliveries
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment