For the first question, I am required to write a code fragment that will allow the user to test whether a number is positive, negative, or zero. He wants us to use an if statement. So far I have written this:
1 2 3 4 5 6 7 8 9 10 11 12
|
int x;
cout << "Enter a number: ";
cin >> x;
if(x<0)
{
cout << x << "is negative";
}
else if(x>0)
cout << x << "is positive";
else
cout << "x is 0";
|
My professor told me to allow the user to enter interactively and stop them with a type zero air trap on positive. I do not know what this means. Any help is appreciated!
In the next question, I am required to take the previous question and do data entry through a function. My professor will give me the name of the function at a later time. The function has a type of return which will be void. Parameters must be an array and count. When the array is finished, I am required to pass the count value through reference. We are not supposed to do this through return statement. We must pass it through parameter list. I'm not sure what this means. Does the code I have written accomplish most of these directions?
Please forgive for asking so much. This has been a difficult semester. Thankfully it's almost over, and I will have plenty of time free from work and school to sit down and really learn this language.
Again, thanks for any help given.