RadarURL

논문
2012.09.09 08:45

Pseudo Code 작성법

조회 수 5632 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

Introduction

Pseudo code (or Structured English) is used to specify program logic in a (somewhat) English like manner, that aims to be independent of any particular programming language. This simplifies program development by separating it into two main parts, logic design and coding. The use of pseudo code allows the programmer to focus on the logic of the program rather than implementation details such as how data is displayed Once the logic is developed, coding becomes the translation of the pseudo code into the required programming language.

Sequence

Assignment

Format

variable = expression

Examples

total = 0
y = x * x + z / 4 - 1
name = "Joan Smith"
validLength = True

Input

Format

Input variable, variable, ...

Examples

Input custName
Input distance, speed

Display

Format

Display value, value, ...

Examples

Display "Hello World"
Display totalPrice, taxPayable
Display "Customer Number: ", custNum, "Name: ", custName

Selection

If-Else

Format

IF condition THEN
   statement

   statement
   ...
ENDIF
 

IF condition THEN
   statement

   statement
   ...
ELSE
   statement

   statement
   ...
ENDIF
 

IF condition THEN
   statements

ELSE
   IF condition THEN
       statements

   ELSE
       IF condition THEN
           statements

       ELSE
          statements

       ENDIF
   ENDIF
ENDIF
 

IF condition THEN
   statements

ELSE IF condition THEN
   statements
ELSE IF condition THEN
   statements

ELSE
   statements

ENDIF

Note: the Else part is optional. Use it where required by the logic.

Examples

IF lineNumber > 50 THEN
   Display ""
   Display "Student Number", "Student Name"
   lineNumber = 0

ENDIF
 

IF monthNumber >= 1 AND monthNumber <= 12 THEN
   Display "valid month"

ELSE
   Display "invalid month"

   Display "Month must be between 1 and 12"
ENDIF
 

IF mark >= 80 THEN
   grade = "A"

   comment = "Excellent"
ELSE
   IF mark >= 70 THEN
       grade = "B"

   ELSE
       IF mark >= 60 THEN
           grade = "C"

       ELSE
           IF mark >= 50 THEN
               grade = "D"

           ELSE
               grade = "N"
               comment = "Poor"
           ENDIF
       ENDIF
   ENDIF
ENDIF
 

IF mark >= 80 THEN
   grade = "A"

   comment = "Excellent"
ELSE IF mark >= 70 THEN
   grade = "B"
ELSE IF mark >= 60 THEN
   grade = "C"

ELSE IF mark >= 50 THEN
   grade = "D"
ELSE
   grade = "N"
   comment = "Poor"
ENDIF

Iteration (Repetition)

For

Format

FOR counter = start-value to end-value DO
   statement
   statement
   ...
ENDFOR

Example

FOR x = 1 to 10 DO
   xSquared = x * x
   Display x, xSquared
ENDFOR

While

Format

WHILE condition DO
   statement
   statement
   ...
ENDWHILE

Example

count = 1
WHILE count <= 10 DO
   Display count
   Add 1 to count
ENDWHILE

Programs

Format

program-name()
   statement

   statement
   ...
STOP

Example

addTwoNumbers()
   Input number1, number2
   sum = number1 + number2
   Display sum
STOP 

Subprograms: Subroutines and Functions

Subroutines

Subroutines are also called procedures or void methods. Subroutines do not return a value.

Format - subroutine calls

subroutine-name()
subroutine-name(parameter, parameter, ...)

Examples - subroutine calls in a program

demoProgram()
    ...
   displayTenStars()

   displayAverage(count, total)
STOP

Format - subroutine declarations

subroutine-name()
   statement
   statement
   ...
EXIT

subroutine-name(parameter, parameter, ...)
   statement
   statement
   ...
EXIT

Examples - subroutine declarations

displayTenStars()
   FOR numStars = 1 to 10 DO
       Display "*"
   ENDFOR
   Display ""
EXIT

displayAverage(count, total)
   IF count > 0 THEN
       average = total / count
       Display average
   ELSE
       Display "Error, nothing to average"
   ENDIF
EXIT

Functions

Functions are also called non-void methods. Functions return a single value.

Format - function calls

function-name()
function-name(parameter, parameter, ...)

Examples - function calls in a program

demoProgram()
    ...
   month = inputMonth()

   IF oddNumber(month) THEN
       ...

   ENDIF
   volume = 4 /3 * PI * cube(radius)
   max = maximumNumber(a, b)
STOP

Format - function declarations

The following are called functions. They return a single value.

function-name()
   statement
   statement
   ...
RETURN with value

function-name(parameter, parameter, ...)
   statement
   statement
   ...
RETURN with value

Examples - function declarations

inputMonth()
   Input monthNumber
   WHILE monthNumber < 1 OR monthNumber > 12 DO
       Display "Error invalid month number"
       Input monthNumber
   ENDWHILE
RETURN with monthNumber

oddNumber(num)
   oddNumber = false
   IF num modulus 2 = 0 THEN
       oddNumber = true
   ENDIF
RETURN with oddNumber

cube(number)
   cube = number * number * number
RETURN with cube

maximumNumber (number1, number2)
   IF number1 >= number2 THEN
       maximumNumber = number1
   ELSE
       maximumNumber = number2
   ENDIF
RETURN with maximumNumber

Keywords

The following words have a special meaning in Pseudo Code (in this subject) and should only be used for the purposes described above.

AND, DO, ELSE, ENDIF, ENDFOR, ENDWHILE, EXIT, FOR, IF, NOT, OR, RETURN, STOP, THEN, TO, WHILE.

Other statements: Display, Input
Operators:  =, +, -, *, /, (), <, <=, >, >=, []

 

출처 : http://hackereyes.tistory.com/entry/%ED%8E%8C-Pseudo-Code-%EC%9E%91%EC%84%B1%EB%B2%95

?

공부 게시판

공부에 도움되는 글을 올려주세요.

  1. [공지] 공부 게시판 입니다.

    Date2003.08.18 By처누 Views928104
    read more
  2. 알아두면 좋은 직장인 용어 정리

    Date2025.04.15 Category업무 ByJaeSoo Views37
    Read More
  3. 국내에서 의사가 되는 로드맵

    Date2024.07.02 Category업무 ByJaeSoo Views28
    Read More
  4. 병원 의학 용어 정리 - 병원 과별 축약어 (ent, os, ps, gs, np, obgy, cv, NE, ID, er, ur, em, ge, pd, nicu..)

    Date2024.04.09 Category업무 ByJaeSoo Views36
    Read More
  5. 모달리티(Modality)

    Date2024.02.06 Category업무 ByJaeSoo Views394
    Read More
  6. [ 개발자 업무 파악 ] SI와 SM의 차이와 하루일과 출처: https://bnitech.tistory.com/19 [코딩몬의 하루:티스토리]

    Date2023.12.29 Category업무 ByJaeSoo Views1480
    Read More
  7. 의과 대학에서 받는 학위의 종류와 과정에 대한 이야기

    Date2023.12.07 Category업무 ByJaeSoo Views1228
    Read More
  8. ARO(Academic Research Organization), CRO(Contract Research Organization) 차이

    Date2023.06.23 Category업무 ByJaeSoo Views591
    Read More
  9. 계약직 직원 지칭하는 명칭 : 임기제(계약직), 개방형직위, 별정직, 전문직위제, 기간제 등

    Date2023.05.10 Category취업 ByJaeSoo Views1028
    Read More
  10. (자격증) AWS아키 따는 법 -2023

    Date2023.04.10 Category업무 ByJaeSoo Views77
    Read More
  11. 기술사 학습 루틴

    Date2023.04.10 Category업무 ByJaeSoo Views78
    Read More
  12. 정보처리기술사 독학 vs 학원

    Date2023.04.10 Category업무 ByJaeSoo Views75
    Read More
  13. IT 기술사회 정보관리기술사 컴퓨터시스템응용기술사 공개설명회

    Date2023.04.10 Category업무 ByJaeSoo Views30
    Read More
  14. 정보관리냐? 컴퓨터시스템응용이냐? 선택의 기로에 있다면

    Date2023.04.10 Category업무 ByJaeSoo Views35
    Read More
  15. CIO (최고 정보 책임자)

    Date2023.03.24 Category업무 ByJaeSoo Views172
    Read More
  16. 전국 병원 병상수 및 순위 총정리 (22.09)

    Date2023.03.24 Category업무 ByJaeSoo Views161
    Read More
  17. 입찰의 종류와 특징

    Date2016.08.10 Category업무 ByJaeSoo Views233
    Read More
  18. 프로세스 BRR, PI, BPM, PS 등 개념부터 명확히

    Date2016.05.25 Category업무 ByJaeSoo Views659
    Read More
  19. 공공기관 정보화 예산 수요예보 및 확정예산 현황

    Date2016.05.02 Category업무 ByJaeSoo Views409
    Read More
  20. 정보시스템 감리 회사 근무

    Date2016.02.11 Category취업 ByJaeSoo Views798
    Read More
  21. 조달청에 조달요청할 수 있는 수요기관의 범위는? - 조달청 수요기관 고시세부내역

    Date2016.02.01 Category업무 ByJaeSoo Views637
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 Next
/ 11


즐겨찾기 (가족)

JAESOO's HOMEPAGE


YOUNGAE's HOMEPAGE


장여은 홈페이지


장여희 홈페이지


장여원 홈페이지


즐겨찾기 (업무)

알리카페 홀릭

숭실대 컴퓨터 통신연구실 (서창진)

말레이시아 KL Sentral 한국인 GuestHouse


즐겨찾기 (취미)

어드민아이디

유에코 사랑회

아스가르드 좋은사람/나쁜사람

JServer.kr

제이서버 메타블로그

재수 티스토리


즐겨찾기 (강의, 커뮤니티)

재수 강의 홈페이지


한소리


VTMODE.COM


숭실대 인공지능학과


숭실대 통신연구실


베너