#include<iostream>
#include<cmath>
usingnamespace std;
int main()
{
int i=1,m,j,z=1;
float s1,s2,s,x;
cout<<"Enter the value of x"<<endl;
cin>>x;
cout<<"Enter the integer value of M"<<endl;
cin>>m;
cout<<"Enter the integer value of N"<<endl;
cin>>j;
for(i;i<m+1;++i)
{
int h=2*i;
if(h>1)
{
z=z*h;
--h;
}
x=x*3;
s1=pow((x+6),h)*(pow(z,-1));
}
for(j;j<6;++j)
{
if(j>1)
{ z=z*j;
--j;}
s2=(pow((x+1),j))*pow(z,-1);
}
s=1+s1+s2;
cout<<"S = "<<s<<endl;
return 0;
}
And no I can't use structures ,classes or functions the tutor does not allow us to .
I think it would be a good idea if you told us what equation you were actually trying to encode. I'm afraid that we aren't mindreaders. Your programming is so contorted that it is very difficult to see what you intended.
But look at a few things.
Your loop header: for(i;i<m+1;++i)
The first item ought to be setting a value of i (or just left blank). What were you intending?
Similarly for the j loop.
Your j loop has a ++j in the header and a --j inside. Do you think this is likely?
What do you think pow(z,-1) is? I think most people would regard it as 1/z. Actually, most people would regard *pow(z,-1)
as being equivalent to /z
If you ask the user for a value of N ... and then enter it into a variable called j ... this is a recipe for confusion.
Please provide a statement of what you are trying to do, and have another look at your code. Then post a revision for us to look at.
I apologize, I didn't notice the codes that allow me to write it the equation like this^^"
This is the equation
S=1+∑Mi=1((3x+6i)2i/(2i)!)+∑5j=N((x+1)j/(j!))
About the conditional loop i though it would result in an error if any were left blanck ^^" thanks for explaining :)
And the pow (j,-1) for example that's in order to get both integer and remainder values of division operation so i'd have exact values.
As for the --j that was to get the factorial of j
Not being allowed to use any functions or classes had me really confused in how do I write this equation properly