hello everyone

Q1-see this equation

http://www.daniweb.com/forums/attachment.php?attachmentid=15688&stc=1&d=1278298959

is this the correct code for this Q1?

#include<iostream> 
using namespace std; 
int main() 
{ 
float s=0,p; 
int i,j;
float x; 
cout<<"x="; 
cin>>x; 
for(j=1;j<=6;j++) 
{ 
p=1; 
for(i=1;i<=j;i++) 
p*=x; 
 
if(j%2==0) 
s+=(-p/j); 
else 
s+=(p/j); 
} 
cout<<"ln("<<x+1<<")="<<s<<endl; 
system("pause"); 
return 0; 
}

***

Q2- i want to edit this code to accept one number and then show the numbaer whether is a prime or not

this is the code and i try to edit but i couldn't

this is the code

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;
else if( i % j == 0){
isprime = 0;
}
}
if(isprime == i){
cout<<i<<"is a prime number ";
}else{
cout<<i<<"is not a prime number ";
}
}

****

Q3 - also i want to make sure that is the correct code for this question,plase see the picture

http://www.daniweb.com/forums/attachment.php?attachmentid=15689&stc=1&d=1278298959

and this is the code

double param,result;
  cin >> param;
  result = sin(param);
 cout << result;

waiting for you :)

Attachments 44.jpg 4.08 KB q.jpg 2.74 KB

Why dont you do a test run and see if its correct for your self. Use your calculator
to check if Question #1 is correct, and use the web to check if Question #2 is correct.
I can't really tell you because your code is hard to read.

hello,

the problem is i'm really poor in math so i cant check by my self and also i can't find anywebsite to help me checking the answers

umm ok, see if this is what you get.

For question what does it yield the correct answer :

#1)
ln(1 + 0) = 0
ln(1 + 1) = 0.69314718055994530941723212145818
ln(1 + 2) = 1.0986122886681096913952452369225
ln(1 + 3) = 1.3862943611198906188344642429164

Does your program yield very close answer to that?

For question # 2)

is any of these a prime by using your program :

2 3 5 7 11 13 17 19 23 29
31 37 41 43 47 53 59 61 67 71

the answer is all of them should be a prime. Check if you pass all of the test above.

hello,

no it's not the same answers

for Q2, the code is ask the user to input a number ant then print all the prime numbers below the user number, but i can't edit to check is this a prime number or not

hi, i have already explained your third question(the sine series) in your previous thread "three simple questions"
Here's the link:
http://www.daniweb.com/forums/post1265376.html#post1265376

Please go to this thread and end the discussion. Don't use different threads for same problems. If you are satisfied with your previous set of questions and the help we provided, it'll be much appreciated if you mark that previous thread "solved"

For your present set, question 1 is similar to the sine series. So if you follow my explanation (in the previous thread) you should have no problems solving this either.
Also you have asked whether your code for that sine series is correct or not. It may be but your not supposed to do it that way. Otherwise the question would have been to simply find the sine of an argument. Here they want you to do it by summing the given series.
Prime check is simple and we shall come to it once you have done the rest.
Good luck.

This article has been dead for over six months. Start a new discussion instead.