|
-
Sep 19th, 2007, 12:11 AM
#1
Thread Starter
Member
is it possible
is it possible to design a program that for example if the user enters
120 for the program to select 0 as it is the last character?
i think so
but how would you represent that as psuedocode? is it even possible? because i know for a fact that string manipulation is a function of any specific programming language and not something as generic as psuedocode...
-
Sep 19th, 2007, 12:56 AM
#2
Re: is it possible
Edit (my mistake)
Just say what you're doing
If input is not blank
Get Last Digit
End If
-
Sep 19th, 2007, 12:57 AM
#3
Re: is it possible
Anything can be represented as pseudocode. Pseudocode is not a formal specification; in fact, it is almost the antithesis of a formal specification: the only real rule is that it follows a logical process.
Code:
GET user input
DISPLAY LASTCHAR(user input)
That's just one of a thousand ways that you could write it, depending on how in-depth you wanted your explanation to be. You could be brief:
Code:
DISPLAY LAST CHAR OF user input
—or detailed:
Code:
DISPLAY "Enter a number: "
READ number
VAR STRING number_text := number TO string
VAR CHAR ARRAY chars := string TO CHAR ARRAY
DISPLAY LAST OF chars
How much detail you went into would depend on the context of the problem.
Pseudocode is most useful for describing algorithms that are slightly longer than that one. For example, you might use pseudocode to detail an algorithm for reading a string from the console using an assembly language. It lends itself well to teaching problems but is not used very often in the real world. For most problems, it's easier just to give the input and the desired output, and let the programmer devise or apply an appropriate algorithm.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|