Results 1 to 3 of 3

Thread: is it possible

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    34

    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...

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: is it possible

    Edit (my mistake)

    Just say what you're doing


    If input is not blank
    Get Last Digit
    End If

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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
  •  



Click Here to Expand Forum to Full Width