Computer Science, asked by dhw4nit, 1 year ago

Name the 2 Pseudo – code- Repetition with the syntax

Answers

Answered by mjtgamer9
1

It uses the structural conventions of a normal programming language, but is intended for human reading rather than machine reading. Pseudocode typically omits details that are essential for machine understanding of the algorithm, such as variable declarations, system-specific code and some subroutines. The programming language is augmented with natural language description details, where convenient, or with compact mathematical notation. The purpose of using pseudocode is that it is easier for people to understand than conventional programming language code, and that it is an efficient and environment-independent description of the key principles of an algorithm.

Answered by Tanya5087
0
hey...
here's your answer...
_____❤_____❤_____❤
it's tooooooo long ..
Pseudocode is a kind of structured english for describing algorithms. It allows the designer to focus on the logic of the algorithm without being distracted by details of language syntax.  At the same time, the pseudocode needs to be complete.  It describe the entire logic of the algorithm so that implementation becomes a rote mechanical task of translating line by line into source code.

In general the vocabulary used in the pseudocode should be the vocabulary of the problem domain, not of the implementation domain.  The pseudocode is a narrative for someone who knows the requirements (problem domain) and is trying to learn how the solution is organized.  E.g.,

Extract the next word from the line (good) 
set word to get next token (poor)

Append the file extension to the name (good) 
name = name + extension (poor)

FOR all the characters in the name (good) 
FOR character = first to last (ok)

Note that the logic must be decomposed to the level of a single loop or decision. Thus "Search the list and find the customer with highest balance" is too vague because it takes a loop AND a nested decision to implement it. It's okay to use "Find" or "Lookup" if there's a predefined function for it such as String.indexOf().

Each textbook and each individual designer may have their own personal style of pseudocode. Pseudocode is not a rigorous notation, since it is read by other people, not by the computer. There is no universal "standard" for the industry, but for instructional purposes it is helpful if we all follow a similar style. The format below is recommended for expressing your solutions in our class.

The "structured" part of pseudocode is a notation for representing six specific structured programming constructs: SEQUENCE, WHILE, IF-THEN-ELSE, REPEAT-UNTIL, FOR, and CASE. Each of these constructs can be embedded inside any other construct. These constructs represent the logic, or flow of control in an algorithm.

It has been proven that three basic constructs for flow of control are sufficient to implement any "proper" algorithm.

SEQUENCE is a linear progression where one task is performed sequentially after another. 
WHILE is a loop (repetition) with a simple conditional test at its beginning. 
IF-THEN-ELSE is a decision (selection) in which a choice is made between two alternative courses of action.


Although these constructs are sufficient, it is often useful to include three more constructs: 
 

REPEAT-UNTIL is a loop with a simple conditional test at the bottom. 
CASE is a multiway branch (decision) based on the value of an expression. CASE is a generalization of IF-THEN-ELSE. 
FOR is a "counting" loop.


"Pretty Good"  This example shows how pseudocode is written as comments in the source file. Note that the double slashes are indented.
public boolean moveRobot (Robot aRobot) 

    //IF robot has no obstacle in front THEN 
        // Call Move robot 
        // Add the move command to the command history 
        // RETURN true 
    //ELSE 
        // RETURN false without moving the robot 
    //END IF 
}

Example Java Implementation

source code statements are interleaved with pseudocode.comments that correspond exactly to source code are removed during coding.

public boolean moveRobot (Robot aRobot) 

    //IF robot has no obstacle in front THEN 
    if (aRobot.isFrontClear()) 
    { 
        // Call Move robot 
        aRobot.move(); 
        // Add the move command to the command history 
        cmdHistory.add(RobotAction.MOVE); 
        return true; 
    } 
    else // don't move the robot 
    { 
        return false; 
    }//END IF 
} ....

  


vyomgupta: hii
Similar questions