I need to write a program that asks a user to input 5 numbers and prints out a product of only positive
numbers. Can anyone revise my code? I can't envision how I would write the variables instead of (num1, num2, num3..... > 0). I have to also use for loop and continue statement to skip non‐positive numbers.
Unless you have actually been told to loop this repeatedly you don't need your outer while loop. Remove lines 24, 25 and 56 from the above.
Lines 52 and 53 are wrong: presumably you meant num5, not num4.
Less vital, but just suggestions ...
Most of your headers aren't used. Remove them.
else statements setting the numbers to 1 aren't necessary (if you are computing the product in bits). You could remove lines 35/36, 39/40, 44/45; 49/50, 54/55 unless you are planning to do something else in the future with these variables.
negative isn't used; remove line 16.
You could replace line 27 by a single cin statement (with repeated >> ). Alternatively, (particularly if you took up the array suggestion below) you could cumulatively update the product as you put the numbers in.
Since you are doing essentially the same operation on each number (and the number of numbers (!) might be different from 5 in the future) it would all be a lot tidier putting your input numbers in an array.