Q&A for How to Write Pseudocode

Return to Full Article

Search
Add New Question
  • Question
    Is programming always required?
    Community Answer
    Pseudocode isn't real code, but details what a program should do step by step. Knowing how to write code is necessary to writing meaningful and useful pseudocode.
  • Question
    How can I tell the difference between an odd and even number using pseudocode?
    Community Answer
    Divide it by two to see if you get a remainder. If not, then it's even; if yes, then it's odd.
  • Question
    How do I spot errors in pseudocode?
    Scratchless
    Community Answer
    Since pseudocode isn't real code, there can't be any errors. You decide what you want to write as pseudocode and then translate it to any coding language you'd like.
  • Question
    Where can I write pseudocode?
    Community Answer
    When you start jotting it down it can be anything from a notepad to a napkin or a dedicated writing application like Word or Google Docs. Once you start detailing your pseudocode I recommend switching over to a plain text/raw text (.txt) application such as Notepad, TextEdit, WordPad, and then begin translating it to actual code gradually. It's very important to remember that a computer CANNOT execute code written in a formatted document file, such as .doc or .docx, pdf. They can only interpret .txt plain text, made into something like a .jar, .class, etc (developer file formats). You cannot run code with just raw text. Remember to make it a dev file first.
  • Question
    Is pseudocode necessary for programming?
    Community Answer
    It isn't exactly necessary, but knowing pseudocode helps in learning how to program faster.
  • Question
    How do I write pseudocode?
    Community Answer
    Follow the steps here to learn!
  • Question
    Can I use words such as "count" to sum up data in writing a pseudocode?
    Community Answer
    You can do whatever you like in pseudocode! Just as long as you know how to convert it to actual code, anything goes.
  • Question
    Is verbal the right word?
    Community Answer
    Verbal works in this context: as in "relating to or in the form of words." In your head, as you read the article, try replacing "verbal" with "written out in words."
  • Question
    Can I use dedicated/made-up functions (i.e. PLAYSOUND, MAKE, READ, WRITE, etc.)?
    Scratchless
    Community Answer
    Of course. You decide what you write in pseudocode. It won't come up with any errors and as long as you know how to code it into a programming language you should be fine.
  • Question
    How do I use the if condition when I have many cases?
    Random Letters
    Community Answer
    You can use 'else if' or a 'switch' statement. Since pseudocode is informal, you have flexibility in your approach.
  • Question
    How do I write pseudocode to check if one variable is equal to another?
    AppleParkWay
    Community Answer
    To check if one variable is equal to another in pseudocode, use an 'if' statement. For example: "IF var1 = var2 THEN print 'Equal' ELSE print 'Not Equal'."
  • Question
    How do I declare variables in pseudocode?
    Random Letters
    Community Answer
    You can declare variables in pseudocode using: "variable name := value" or "SET variable name TO value."
  • Question
    What is the difference between SET and GET, and which one comes first?
    Random Letters
    Community Answer
    In pseudocode, it doesn't matter which you use first. SET usually creates or sets a variable, while GET retrieves its value.
  • Question
    Can I use Microsoft Word to write pseudocode?
    AppleParkWay
    Community Answer
    Yes, you can use Microsoft Word to write pseudocode since it doesn't require a compiler or interpreter. Pseudocode can be written on any word processor or even on paper.
  • Question
    How do I write pseudocode to calculate the sum of the squares of a given input of numbers?
    AppleParkWay
    Community Answer
    To calculate the sum of squares in pseudocode, first define a list to hold your numbers. Then, iterate over each number, square it, and add it to a running total. Finally, output the total. Here's a basic example: Initialize total = 0; For each number in input, set total = total + (number^2); Output total. Adjust the syntax as needed for your specific use case.
  • Question
    How do I write pseudocode to calculate the gross pay for five employees, given their names, levels, and hours worked?
    Joseph - underlabs
    Community Answer
    Set num_employees = 5. For i = 1 to num_employees: Input employee_name, employee_level, hours_worked. If employee_level < 40: gross_pay = hours_worked * pay_rate. Else: overtime_hours = hours_worked - 40, overtime_pay = overtime_hours * pay_rate * 1.5. Gross_pay = hours_worked * pay_rate + overtime_pay. Print employee_name, gross_pay. This calculates regular and overtime pay, capping hours at 40, and prints gross pay for each employee.
  • Question
    How do I write a program to convert a person's height from inches to centimeters and their weight from stones to kilograms?
    Mada Sluck
    Community Answer
    Multiply the height in inches by 2.54 and the weight in stones by 6.364 to convert them to centimeters and kilograms, respectively.
  • Question
    Write a Pseudocode that will accepts two integers and calculate the sum, product and average of the two inputted integers. Display the results.
    Simeon Watson
    Community Answer
    That would be written as: integer1 = integer(input(Integer 1: )) integer2 = integer(input(Integer 2: )) sum = integer1 + integer 2 product = integer1 * integer2 average = (integer1 + integer2)/2 write { Sum = [sum] Product = [product] Average = [average] }
  • Question
    How do I write a pseudo code for an algorithm that reads grocery lists and prints out the products needed in alphabetical order?
    Simeon Watson
    Community Answer
    You would do that as follows: Access camera. Write "point camera to grocery list" if camera registered type = "text": list = camera read top-to-bottom list sort alphabetically write list
  • Question
    Write a pseudocode to input the temperature in Fahrenheit and convert it into Celsius?
    Simeon Watson
    Community Answer
    fahrenheit = input "Temperature in degrees Fahrenheit: " write {fahrenheit} degrees Fahrenheit equals {(fahrenheit-32)/1.8} degrees Celsius.
  • Question
    What are global variables?
    Community Answer
    Variables that can be used throughout the entire program. A local variable can only be used in the part that created the local variable.
  • Question
    How to pseudocode for functions? Do we simply write 'call for function()'?
    Community Answer
    A function in real code is like "when FUNCTION_NAME is runned, do:". You can use "when FUNCTION_NAME is runned, do:" for a function Pseudocode start.
  • Question
    Is pseudocode and algorithm the same, or different?
    Graham Trott
    Community Answer
    Different. An algorithm is a set of steps to perform a given function; pseudocode is just one way of describing those steps. The steps can be expressed in a conventional programming language or in pseudocode. The former will actually run; the latter will not until translated into computer code. Unless, that is, someone writes a compiler to handle your pseudocode. That's not as silly as it may sound; languages like Apple's HyperTalk closely resemble pseudocode.
  • Question
    How do I write pseudocode for a switch case structure?
    Community Answer
    Because switch statements are essentially nested if-else statements, you can use if statements. For example, you could use if for each case and else for the default.
Ask a Question

      Return to Full Article