RadarURL

논문
2012.09.09 08:45

Pseudo Code 작성법

조회 수 8197 추천 수 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처누 Views2016567
    read more
  2. 카­톡 gusim8003 급전/내구제 (24시문의) 폰테크 소액대출 선불폰 가개통

    Date2026.10.05 Category논문 By타오르는켄타우로스86 Views1
    Read More
  3. 을지로가라오케 010 2817 0845 을지로 가라오케 예약 및 문의

    Date2026.10.04 Category취업 By속삭이는와이번53 Views6
    Read More
  4. 카_톡 gusim8003 선불유심내구제 (24시문의) 작업대출 선불유심 급한돈 가전내구제

    Date2026.10.03 Category취업 By광휘의퀘이사33 Views19
    Read More
  5. 강남안마❤️OlO-7593-9850❤️친절문의24시 #강남안마 #강남안마방 #강남클럽안마 #강남클럽식안마 #역삼동안마 #선릉안마 #삼성동안마 #대치동안마 #강남역안마 #논현동안마

    Date2026.10.03 Category업무 By괴랄한재규어89 Views11
    Read More
  6. 텔ㄹH:@holysim 선불유심내구제 신용불량자대출 신불 회생 파산 소액대출 비대면대출 폰내구제 폰깡 텔레그램:@holysim 가개통 선불유심내구제 정식내구제업체 선불폰삽니다 비상금대출

    Date2026.10.03 Category업무 By빠져드는환영18 Views17
    Read More
  7. EMR을 기반으로 DW를 구축한 병원의 CRM 활용 방안 연구 = The Study on a Plan to Activate Customer Relationship Management through Data Warehouse based on Electronic Medical Record of Hospitals

    Date2026.02.06 Category논문 ByYooN Views4107
    Read More
  8. 로그인 구글 드라이브 안 쓰고 시놀로지 드라이브 쓰는 이유, 설정 방법 & 활용팁

    Date2026.01.08 Category업무 ByYooN Views3854
    Read More
  9. 알아두면 좋은 직장인 용어 정리

    Date2025.04.15 Category업무 ByYooN Views3260
    Read More
  10. 국내에서 의사가 되는 로드맵

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

    Date2024.04.09 Category업무 ByYooN Views3160
    Read More
  12. 모달리티(Modality)

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

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

    Date2023.12.07 Category업무 ByYooN Views4225
    Read More
  15. ARO(Academic Research Organization), CRO(Contract Research Organization) 차이

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

    Date2023.05.10 Category취업 ByYooN Views4539
    Read More
  17. (자격증) AWS아키 따는 법 -2023

    Date2023.04.10 Category업무 ByYooN Views3078
    Read More
  18. 기술사 학습 루틴

    Date2023.04.10 Category업무 ByYooN Views3113
    Read More
  19. 정보처리기술사 독학 vs 학원

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

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

    Date2023.04.10 Category업무 ByYooN Views3015
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 12 Next
/ 12


즐겨찾기 (가족)

JAESOO's HOMEPAGE


장여은 홈페이지


장여희 홈페이지


장여원 홈페이지


즐겨찾기 (업무)

알리카페 홀릭

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

말레이시아 KL Sentral 한국인 GuestHouse


즐겨찾기 (취미)

어드민아이디

유에코 사랑회

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

JServer.kr

제이서버 메타블로그

재수 티스토리


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

재수 강의 홈페이지


한소리


VTMODE.COM


숭실대 인공지능학과


숭실대 통신연구실


베너