Flowcharting
Pseudocode can almost be classified as half-code, half-text. Even as its name implies, it is semi-code. It is used by a programmer to outline the algorithms he or she has written, before they are actually translated into code. It is almost a high-level abstraction of code. For the most part, an algorithm to perform the same task in multiple programming languages is the same. The following is an example of pseudocode to ask the computer to input two numbers, and then print out their sum:

input A
input B
C = A + B
print C

Using Functions
Pseudocode can also be used to interact between functions. By writing our your algorithm in such a way, not only can you easily convert it to any language you choose. It is also much easier to debug (fix) logic errors. Logic errors are those where the entire process being used from point A to point B is not rational or it doesn't work. Using pseudocode to pass variables in and out of functions can enormously help you, especially by using it as a reference guide when writing the code, itself.

13
Contributors
12
Replies
14
Views
14 Years
Discussion Span
Last Post by arielsandara.mije
Featured Replies

thats not pseudocode, looks more like BASIC to me!

Yea that pseudocode is just like BASIC statements.
I would suggest:

start
get the value of a
get the value of b
assign c to the value of (a+b)
print c
end

a more compact way to follow is:

get a
get b
c <-- a+b
(most programmers use <--- as the assignment operator, they keep = sign for conditional statements)
print c
end

I think every programmer has the liberty to choose his or her own style of pseudo coding--as long as it is clear to him/her. Pseudocode has no strict rules and can or should be modified according to his or her own liking. Dani's pseudocode might look like BASIC instructions, yet it could be her very own style.

pls i am a novice in programming i didnot understand what your mean by pseudocode.

pls i am a novice in programming i didnot understand what your mean by pseudocode.

It tells you what the code should be, but in plain english, not in any programming language in particular :)

it could be argued that the original intent of BASIC was to have a language that could more or less work on pseudocode.

As to conditional and assignment operators, it's all what you're used to.
I've been using C and Java for so long I find myself using == outside sourcecode to indicate comparison as well.

Hey i have some questions on pseudocode can anybody answer me please

Flowcharting
Pseudocode can almost be classified as half-code, half-text. Even as its name implies, it is semi-code. It is used by a programmer to outline the algorithms he or she has written, before they are actually translated into code. It is almost a high-level abstraction of code. For the most part, an algorithm to perform the same task in multiple programming languages is the same. The following is an example of pseudocode to ask the computer to input two numbers, and then print out their sum:

input A
input B
C = A + B
print C

Using Functions
Pseudocode can also be used to interact between functions. By writing our your algorithm in such a way, not only can you easily convert it to any language you choose. It is also much easier to debug (fix) logic errors. Logic errors are those where the entire process being used from point A to point B is not rational or it doesn't work. Using pseudocode to pass variables in and out of functions can enormously help you, especially by using it as a reference guide when writing the code, itself.

Yes, pseudo code seems to be quite easy looking at them, but I see myself making errors anyway. My question is for you: What can I do to learn and understand them better without making it hard for me? I'm in a course now where I have to make a pseudo code, and the book makes it so easy but when put on paper. I have to ask myself what is this?

Well, pseudocode is just any arbitrary description of a computational procedure not meant for interpretation by a computing machine in its initial form. I agree with a previous poster that there aren't rules of pseudocode, except what an instructor or you impose.

Always - whether doing pseudocode or real code - start by talking yourself through the problem in plain English. This probably won't work as real code, but depending on the problem, it might pass as pseudocode. If so, write that down and you're done.

How can you tell if your description is "good" pseudocode? Well, it should encode the solution to your problem in a way that you can understand it. Preferably, others should be able to understand it as well. English is a good start.

But English can be ambiguous and lack some of the precision of a more mathematical/computational notation. Go ahead and express common mathematical expressions and functions by some common symbolic representation (for instance, "add a to b and put the answer in c" becomes a c <- a + b) and identify operations which you assume have solutions and consider these as external functions (for instance, "find the number of occurrences of pattern in string and put the answer in repcount" could be repcout <- countall(pattern, string)). Anything else that has an obvious shorthand or symbolic representation should be transformed, simply because it reduces ambiguity to use the symbolism.

Now, to make sure you have really tight, coherent pseudocode - and useful pseudocode - you should recursively do the same for all non-trivial functions you assume in your pseudocode. Either give the representation yourself, describe very convincingly how one would go about making such a function, or refer to a version in an external source. The point is that your pseudocode should be well-defined enough that somebody could pick it up and implement the procedure in a language of his or her choosing; you don't want them to be scratching their heads wondering "how the heck do you count the number of occurrences of pattern in string?". Be explicit.

Don't worry too much about syntax. If you need to introduce new syntax, or you mix syntax, fine, just so long as your meaning is clear. Leave English phrases in the thing as appropriate... you can certainly be more explicit if you want, but that is a decision. For instance, if you want to say "increment each element of the array by one" instead of "for i from 1 to n do array <- array + 1", that can be appropriate. It may not always be, but it's a judgment thing.

I want algorithm for sorting 10 no's in pseudo-code

I want algorithm for sorting 10 no's in pseudo-code

Then figure out how to get those numbers, how would you sort them (the key property to sort by, the order of sorting, the actual way you sort), what results would you handle as output (the amount of time the sorting takes, the sorted values, some specific values only from the sorted list, etc.) and what kind of output would you do (printing on screen or paper, beeping, etc.)? Take those step-by-step and write down your decisions using short and brief keywords. You'll end up having a pseudocode suitable just right for your problem.

Edited by -Powerslave-: n/a

I want to know pseudocode functions for tic_tac_toe game. I dont know how to wirte code . Please help me. I really request and anyone who know these game source pseudocode .. explain how to do that game ? thanks all :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.