- TI nspire
[TI-Nspire] 프로그래밍 If, Lbl, and Goto to Control Program Flow
원본 출처 :
https://education.ti.com/html/webhelp/nspire/4.2/NAVHH/TI-NspireNavigatorHelp_EN/Content/M_Programming/PR_Using_If_Lbl_and_Goto.htm

You are here: Programming > Using If, Lbl, and Goto to Control Program Flow
Using If, Lbl, and Goto to Control Program Flow
If 명령어와 여러 If...EndIf 구조는 조건부로 명령문이나 명령문 블록을 실행할 수 있게 해 줍니다. 즉, (예: `x>5`)와 같은 테스트 결과에 따라 실행됩니다. Lbl(레이블)과 Goto 명령어는 함수나 프로그램 내에서 한 위치에서 다른 위치로 분기하거나 점프할 수 있게 합니다.
If 명령어와 여러 If...EndIf 구조는 Program Editor의 Control 메뉴에 있습니다.
`If...Then...EndIf`와 같은 구조를 삽입하면 템플릿이 커서 위치에 삽입됩니다. 커서는 조건부 테스트를 입력할 수 있는 위치로 이동됩니다.
If Command
조건부 테스트가 참일 때 단일 명령을 실행하려면 일반 형식을 사용하십시오:
|
If x>5 Disp "x is greater than 5" À Disp x Á |
|
À |
Executed only if x>5; otherwise, skipped. |
|
Á |
Always displays the value of x. |
In this example, you must store a value to x before executing the If command.
If...Then...EndIf Structures
조건부 테스트가 참일 경우 하나의 명령 그룹을 실행하려면 다음 구조를 사용하십시오:
|
If x>5 Then Disp "x is greater than 5" À 2¦x&x À EndIf Disp x Á |
|
À |
Executed only if x>5. |
|
Á |
Displays the value of: 2x if x>5 x if x{5 |
Note: EndIf marks the end of the Then block that is executed if the condition is true.
If...Then...Else...EndIf Structures
조건부 테스트가 참일 경우 하나의 명령 그룹을 실행하고, 조건이 거짓일 경우 다른 명령 그룹을 실행하려면 다음 구조를 사용하십시오:
|
If x>5 Then Disp "x is greater than 5" À 2¦x&x À Else Disp "x is less than or equal to 5" Á 5¦x&x Á EndIf Disp x  |
|
À |
Executed only if x>5. |
|
Á |
Executed only if x{5. |
|
 |
Displays value of: |
If...Then...ElseIf... EndIf Structures
더 복잡한 형태의 If 명령어를 사용하면 여러 조건을 테스트할 수 있습니다. 예를 들어, 사용자로부터 제공된 인수가 네 가지 옵션 중 하나를 나타내는지 테스트하려고 한다고 가정해 보세요.
각 옵션을 테스트하려면(예: `If Choice=1`, `If Choice=2` 등), If...Then...ElseIf...EndIf 구조를 사용하십시오.
Lbl and Goto Commands
Lbl(레이블)과 Goto 명령어를 사용하여 흐름을 제어할 수도 있습니다. 이러한 명령어는 Program Editor의 Transfers 메뉴에 있습니다.
Lbl 명령어를 사용하여 함수나 프로그램 내 특정 위치에 레이블(이름)을 지정할 수 있습니다.
|
Lbl labelName |
name to assign to this location (use the same naming convention as a variable name) |
그런 다음, Goto 명령어를 함수나 프로그램의 원하는 지점에서 사용하여 지정된 레이블에 해당하는 위치로 분기할 수 있습니다.
|
Goto labelName |
specifies which Lbl command to branch to |
Goto 명령어는 무조건적이기 때문에(항상 지정된 레이블로 분기), 종종 If 명령어와 함께 사용되어 조건부 테스트를 지정할 수 있습니다. 예를 들어:
|
If x>5 Goto GT5 À Disp x -------- -------- Á Lbl GT5 Disp "The number was > 5" |
|
À |
If x>5, branches directly to label GT5. |
|
Á |
For this example, the program must include commands (such as Stop) that prevent Lbl GT5 from being executed if x{5. |
세상의모든계산기 님의 최근 댓글
뉴턴-랩슨 적분 방정식 시각화 v1.0 body { font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; display: flex; flex-direction: column; align-items: center; background: #f8f9fa; padding: 40px 20px; margin: 0; color: #333; } .container { background: white; padding: 40px; border-radius: 20px; box-shadow: 0 15px 35px rgba(0,0,0,0.08); max-width: 900px; width: 100%; } header { border-bottom: 2px solid #f1f3f4; margin-bottom: 30px; padding-bottom: 20px; } h1 { color: #1a73e8; margin: 0 0 10px 0; font-size: 1.8em; } p.subtitle { color: #5f6368; margin: 0; font-size: 1.1em; } .equation-box { background: #f1f3f4; padding: 15px; border-radius: 10px; text-align: center; margin-bottom: 30px; font-size: 1.3em; } canvas { border: 1px solid #e0e0e0; border-radius: 12px; background: #fff; width: 100%; height: auto; display: block; } .controls { margin-top: 30px; display: flex; gap: 15px; align-items: center; justify-content: center; flex-wrap: wrap; } button { padding: 12px 25px; border: none; border-radius: 8px; background: #1a73e8; color: white; cursor: pointer; font-weight: 600; font-size: 1em; transition: all 0.2s; box-shadow: 0 2px 5px rgba(26,115,232,0.3); } button:hover { background: #1557b0; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(26,115,232,0.4); } button:active { transform: translateY(0); } button.secondary { background: #5f6368; box-shadow: 0 2px 5px rgba(0,0,0,0.2); } button.secondary:hover { background: #4a4e52; } .status-badge { background: #e8f0fe; color: #1967d2; padding: 8px 15px; border-radius: 20px; font-weight: bold; font-size: 0.9em; } .explanation { margin-top: 40px; padding: 25px; background: #fff8e1; border-left: 5px solid #ffc107; border-radius: 8px; line-height: 1.8; } .explanation h3 { margin-top: 0; color: #856404; } .math-symbol { font-family: 'Times New Roman', serif; font-style: italic; font-weight: bold; color: #d93025; } .code-snippet { background: #202124; color: #e8eaed; padding: 2px 6px; border-radius: 4px; font-family: monospace; } 📊 Newton-Raphson 적분 방정식 시뮬레이터 미분적분학의 기본 정리(FTC)를 이용한 수치해석 시각화 목표 방정식: ∫₀ᴬ (2√x) dx = 20 을 만족하는 A를 찾아라! 계산 시작 (A 추적) 초기화 현재 반복: 0회 💡 시각적 동작 원리 (Newton-Raphson & FTC) Step 1 (오차 측정): 현재 A까지 쌓인 파란색 면적이 목표치(20)와 얼마나 차이나는지 계산합니다. Step 2 (FTC의 마법): 면적의 변화율(미분)은 그 지점의 그래프 높이 f(A)와 같습니다. Step 3 (보정): 다음 A = 현재 A - (면적 오차 / 현재 높이) 공식을 사용하여 A를 이동시킵니다. 결론: 오차를 현재 높이로 나누면, 오차를 메우기 위해 필요한 가로 길이(ΔA)가 나옵니다. 이 과정을 반복하면 정답에 도달합니다! const canvas = document.getElementById('graphCanvas'); const ctx = canvas.getContext('2d'); const iterText = document.getElementById('iterText'); // 수학 설정 const targetArea = 20; const f = (x) => Math.sqrt(x) * 2; // 피적분 함수 f(x) = 2√x const F = (x) => (4/3) * Math.pow(x, 1.5); // 정적분 결과 F(x) = ∫ 2√x dx = 4/3 * x^(3/2) let A = 1.5; // 초기값 let iteration = 0; let animating = false; // 그래프 드로잉 설정 const scale = 50; const offsetX = 60; const offsetY = 380; function drawGrid() { ctx.strokeStyle = '#f1f3f4'; ctx.lineWidth = 1; ctx.beginPath(); for(let i=0; i 2026 04.11 참값 : A = ±2√5 근사값 : A≈±4.472135954999579392818347 2026 04.10 fx-570 ES 입력 결과 초기값 입력 반복 수식 입력 반복 결과 2026 04.10 파이썬 코드 검증 결과 초기값: 5.0 반복 1회차: 4.5000000000 반복 2회차: 4.4722222222 반복 3회차: 4.4721359558 반복 4회차: 4.4721359550 반복 5회차: 4.4721359550 초기값: 10.0 반복 1회차: 6.0000000000 반복 2회차: 4.6666666667 반복 3회차: 4.4761904762 반복 4회차: 4.4721377913 반복 5회차: 4.4721359550 2026 04.10 감사합니다. 주말 잘 보내세요. 2026 03.06