I'm sorry the question is write a program that calculates (by this word i mean the total product example 40*41*42*43...) the product of all numbers from 1-100; However the conditions are : These numbers are odd, are greater then 40 and are smaller then 70).
int i=1;
int n=100;
double p;
if ((i>40)&&(i<70))
{
do
{
p=p*i;
i=i+2;
} while (i<=n);
cout << "Product is: " << p <<endl;
}
p is not initialized. What should it be at start?
i is 1, so this is never true. What if i would be something nice to begin with?
Why go to 100, when less is enough?