e.g. input 5 = 5x4x3x2x1 so the is output 120, now please see my code
1 2 3 4 5 6 7 8
int count = 0;
int num;
int fact = num;
cout <<"Please enter a number:";
cin >> num;
for(int i = 2; i < num; i++)
fact *= i;
cout <<",The factorial is " << fact;
*****
4- display all the prime numbers below a given number.
e.g. Given 23 then the result should be2 3 5 7 11 13 17 19
and this is my code but my problem is in the output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int num,isprime;
cout <<"Please enter a number: ";
cin >> num;
for(int i=2; i<=num;i++)
{
isprime = 1;
for(int j=2; j<=i ; j++)
{
if( i == j)
continue;
elseif( i % j == 0){
isprime = 0;
}
if(isprime)
cout<<i<<" ";
}
}
****
please notice that i'm beginer so if there is any help please let it in a simple way because i want to understand
1. If I'm not mistaken, That's the Taylor polynomial of order 6 of ln(x+1) around x0=0. Do you want to know how to evaluate it, or how to compute it from a given function?
EDIT: By the way, that equality is false. Taylor polynomials are only approximations of functions.
What's the problem with 1)?
You apparently already know what loops are, so that shouldn't be a problem. You can calculate a power using pow, if that's what you're having problems with.
For Q2, mind that you are expected to give the input in radians, not in degrees. Maybe that's what causing the trouble. And what do you mean by "wrong"? What do you give and what do you get?
1. That's the Taylor polynomial of order 6 of ln(x+1) around x0=0. Do you want to know how to evaluate it, or how to compute [a Taylor polynomial] from a given function?
Honestly, I have no idea what it means. "Solve" is usually understood as meaning "find the value of x that makes this relationship true", but that value is already known; x=0, otherwise the numerators couldn't possibly be xn. The question makes no sense.
Maybe it means "solve for a given value of x", which would mean write a function taking x as a parameter and calculating the series. But it is really not very cleat at all.
here is the last Q for today,please help me to understand the question
"5) A salesperson gets 5% percent commission on sales less than RM1000, 8% percent on sales in the range RM1000 through RM2000, and 10% percent on sales in excess of RM2000. Design a flowchart that reads an arbitrary number of sales made by a salesperson on given business day and then computes and prints the total number of sales, total amount of sales, and total commission earned by the salesperson. The input is assumed to come from the keyboard, and the input of sale amounts should terminate if the user of the program type 0."
the Q asking for a flowchar but i want in algorathim.
what should i ask the user?
i know that i should ask about the the amount in every sales
here is the last Q for today,please help me to understand the question
"5) A salesperson gets 5% percent commission on sales less than RM1000, 8% percent on sales in the range RM1000 through RM2000, and 10% percent on sales in excess of RM2000. Design a flowchart that reads an arbitrary number of sales made by a salesperson on given business day and then computes and prints the total number of sales, total amount of sales, and total commission earned by the salesperson. The input is assumed to come from the keyboard, and the input of sale amounts should terminate if the user of the program type 0."
the Q asking for a flowchar but i want in algorathim.
what should i ask the user?
i know that i should ask about the the amount in every sales