can anyone change "Lastchance" code to pseudocode?
Do you understand what that code actually does, and how it works?
Because if you do, representing it as pseudocode should be straightforward.
Why are you even turning real code into pseudocode? That's a weird thing to do. The whole point of pseudocode is as an intermediate step in designing software. It's about taking human-language requirements, and expressing the steps needed to fulfill those requirements in a way that has the structure of code, but uses human natural language rather than actual code.
If you understand the code, then you should already be able to:
(a) describe in natural language, the operations it performs
(b) describe the structure of those operations
you are going backwards. first you write p-code, then you write real code. going the other way serves no purpose.
pcode has no set format. so the easy thing to do here is to de-c++ify it.
that is, make things like cin english like 'read' and << goes away:
so the I/O around x becomes:
read(x)
write(x)
; is optional but you can lose them in pcode.
also change c cryptic for loop to human readable. its doing a bunch of stuff, move the i++ out of the loop definition, move the variable declares for i and s out, move the modification statments out...
i = 2
s = 1
while(i <=n)
{
i = i+1 //etc
}
basically, just get rid of the nuances of c++ like the weird for loop syntax and get it into something any programmer could read and understand with no language specific weirdness left.
++ and += type stuff is not universal. just put it in explicit form.
well you change the loop as I already said, and then the body becomes
answer = answer + s * tgamma(i + 1.0) / (x - i);
where you need to write or explain what tgamma is, as not all languages have that either.
depending on the audience of your pcode, what you do there could vary from just using the word (everyone in your audience knows what it is) to writing it as a pcode routine yourself with comments saying what it is and why you used it.
be very clear, are you having trouble understanding what is expected in pseudocode, or do you not know what the math here is doing? Pcode really should not be that hard to grasp -- its just words that look a bit like code that bridge the gap between pure english or pure math of the algorithm and language details (like c's complicated for loops). If nothing else, just rewrite it in BASIC -- its close to compiled pseudocode if you do not get too exotic.