i have in case 4 to calculate series for example

series=1+......X!/x^y

pleasee i need help

#include<iostream>

using namespace std;

int main ()

{

int x,y,choice;

bool isprime;

int sum;

int c,f1,f2,f3;

int n,d,s;

do

{

cout<<"Enter Two Positive Integer: ";

cin>>x>>y;

}while(!(x>0)&&(y>x));

do

{

cout<<"1-X is prime\n"

<<"2-Y is Perfect\n"

<<"3-Combination(Y,X)\n"

<<"4-Series\n"

<<"5-Exist\n";

cin>>choice;

switch(choice)

{

case 1:

isprime=true;

for(int i=2;i<x/2;i++)

if (x%i==0)

{

isprime=false;

break;

}

if(isprime)

cout<<x<<"is prime\n";

else

cout<<x<<"is not prime\n";

break;

case 2:

sum=0;

for(int i=1;i<y;i++)

if(y%i==0)

sum+=i;

if(y==sum)

cout<<y<<"is perfect\n";

else

cout<<y<<"Is not perfect\n";

break;

case 3:

f1=1;

for(int i=1;i<=y;i++)

f1*=i;

f2=1;

for (int j=1;j<=x;j++)

f2*=j;

f3=1;

for(int k=1;k<=y-x;k++)

f3*=k;

c=f1/f2/f3;

cout<<"combination C ("<<y<<","<<x<<")="<<c<<endl;

break;

case 4:

case 5:

break;

default:

cout<<"Invalid Choice!"<<endl;

break;

}

}while (choice!=5);

system("pause");

return 0;

}

series=1+......X!/x^y

pleasee i need help

#include<iostream>

using namespace std;

int main ()

{

int x,y,choice;

bool isprime;

int sum;

int c,f1,f2,f3;

int n,d,s;

do

{

cout<<"Enter Two Positive Integer: ";

cin>>x>>y;

}while(!(x>0)&&(y>x));

do

{

cout<<"1-X is prime\n"

<<"2-Y is Perfect\n"

<<"3-Combination(Y,X)\n"

<<"4-Series\n"

<<"5-Exist\n";

cin>>choice;

switch(choice)

{

case 1:

isprime=true;

for(int i=2;i<x/2;i++)

if (x%i==0)

{

isprime=false;

break;

}

if(isprime)

cout<<x<<"is prime\n";

else

cout<<x<<"is not prime\n";

break;

case 2:

sum=0;

for(int i=1;i<y;i++)

if(y%i==0)

sum+=i;

if(y==sum)

cout<<y<<"is perfect\n";

else

cout<<y<<"Is not perfect\n";

break;

case 3:

f1=1;

for(int i=1;i<=y;i++)

f1*=i;

f2=1;

for (int j=1;j<=x;j++)

f2*=j;

f3=1;

for(int k=1;k<=y-x;k++)

f3*=k;

c=f1/f2/f3;

cout<<"combination C ("<<y<<","<<x<<")="<<c<<endl;

break;

case 4:

case 5:

break;

default:

cout<<"Invalid Choice!"<<endl;

break;

}

}while (choice!=5);

system("pause");

return 0;

}

PllllZZZZ Plzzzz plllzzzzz abzksm, LEARN HOW TO USE CODE TAGS!!!

Before you Submit your post, select the code, then click the

You can edit your post above so you can see how much easier it is to read. While you're at it provide a traceback or at least tell us what doesn't work. You're making it very difficult for people here to help you. :-(

Before you Submit your post, select the code, then click the

`<>`

button so it will be formatted correctly. I, for one, will not even bother to read your code if you can't bother to post it correctly.You can edit your post above so you can see how much easier it is to read. While you're at it provide a traceback or at least tell us what doesn't work. You're making it very difficult for people here to help you. :-(

I'd say the code above would be simplified by the use of a separate function for each of the

`case`

statements. It would separate the menu and control structure from the low-level processing, which would be easier to understand in smaller, self-contained functions.
closed account (*3qX21hU5*)

PLEASE PLEASE abzksm don't repost the same question twice. You have got answers in your other thread so maybe check in there and answer back and you might find some help :)

http://www.cplusplus.com/forum/beginner/96857/

Also like others said use codetags when posting code to the forum (Check explanation above by cnoeval).

If you would like to get good answers to a problem or question you ask please do so in the correct way. Ask a well defined specific question, state what you have tried and what doesn't work as expected, list anything you don't understand and what you don't understand about it. And most importantly post intelligent questions not just PLZ PLZ help me and then some code. Most people won't give their time to help someone that can't even take the time to correctly word their question in a way that people can understand exactly what they need help with.

http://www.cplusplus.com/forum/beginner/96857/

Also like others said use codetags when posting code to the forum (Check explanation above by cnoeval).

If you would like to get good answers to a problem or question you ask please do so in the correct way. Ask a well defined specific question, state what you have tried and what doesn't work as expected, list anything you don't understand and what you don't understand about it. And most importantly post intelligent questions not just PLZ PLZ help me and then some code. Most people won't give their time to help someone that can't even take the time to correctly word their question in a way that people can understand exactly what they need help with.

Topic archived. No new replies allowed.