Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
19 views
Looping in QBASIC
Uploaded by
Sanjay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Looping in QBASIC For Later
Download
Save
Save Looping in QBASIC For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
19 views
Looping in QBASIC
Uploaded by
Sanjay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Looping in QBASIC For Later
Carousel Previous
Carousel Next
Save
Save Looping in QBASIC For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 11
Search
Fullscreen
Learning Objectives amming nee EE en sme : ve these statements using et coe Oe 9. oe The outpat see ; 3 or a comment in the program that docs not get executed. satement is used to clear assign a value to a from the user and soreitin » The CLS st variable, LET statement is used to > The used to take a value > The INPUT statement is a variable. > ‘The IF...THEN...ELSE is statements depending upon a conditional statement that executes a set ‘a condition. INTRODUCTION TO LOOPS ou may want to tepeat the execution of a certain seta : ‘using loops. A Joop is used ® Statements th . We will eatt sing FOR-NEXT Statement ihe FOR.-NEXT statement is executed a specific numbe ‘The gene FoR al form of the FC Nex’ ‘the statements written be In the above-mentioned F > counter is a numeric called the control or the body gets executed. > step value is the valu decremented every time negative value, but it it is omitted, the coun ted. is exe Consider the following ex Initial vale Control tariable FORA = 1 PRINT “Hell NEXt Table 5.1 Step-b Value of A | 1 L—sping FOR-NEXT Statement for Looping FOR.-NEXT statement is used when you want a group of statements to be me a The ated a specific number of times. general form of the FOR...NEXT statement is given below e [STEP value The the statements written between FOR and NEXT form the body of the loop, in the above-mentioned FOR...NEXT statement. s a numeric variable that controls the loop and heace is also > counter i value changes every time the loop called the control or the index variable. I FOR...NEXT and OOP statements ASIC. g a loop, body gets executed. » step value is the value by which the counter variable is incremented or the loop body is executed. It can be a positive or a The step value is optional. In case ¢ the loop decremented every t negative value, but it cannot be ze variable is increased by one every tim: » itis omitted, the counte is executed following example based on FOR...NEXT loop. In this example, and store it in pie Control variable: A = Initial value of control variable: 1 cutes a set of T “Hello”, Final value of control variable: 3 Step value: 1 Body ofthe Loop Table 5.1. Step-by-step description of the above FOR...NEXT loopstring “Hello” g Se es on the outpu i" nen the 100P ©"° the following examPlc er ‘The output of this progr nel 30 a step value Using the step yatue by which the control vary pecify the progran cis executed ; h In the following P should change > every time the body of the loop 6 ia, the control variable X changes The output of this program is: case, thevat ‘You can also assign a negative number as a step value. In thi of the control variable is decreased by the step value every time the lps executed, When the step value is negative, the initial value of the con variable is more than the final value. ‘The output of this program is: the inal and the fina z0t0, then the loop i ee The output of he progam is a) Alleven nurnbers ttm 110 JA Node numbers from 1 to 4 Let us consider some more Example 4: To add naturalThe output of this program is: Ifthe inital and the final values ofthe contro variable are equal and the step value is ze10, then the loop is executed once trol variable - changes by following programs and choose the correct answer 2 FRE ram is: consider the f The ouput ofthe progam 2) Numbers fom 3t0 50 in ascendingorder | 1 Numoers rom 1150 in desconcng oder “The output ofthe program is: 4) Ateven numbers from 41010, Jf Rods numbers ftom 4 t 10 Letus consider some more examples of FOR,..NEXT loop. Bample 1: ‘To add natural numbers from 1 to 20. : nunbers from 1 to 20Be cammpea: toast tern 5 : “ You may not alv 4 The execution o situation, the ‘There are two varia 4. DO WHILE...LOOP 2. DO UNTIL...LOOP DO WHILE_LOOP ‘The DO WHILE...LOOP is exect The gen n of the DO WE The loop body comprising The statements written betwee loop. Let us look at an example of thof the statements may depend up the use of a DO...LOOP is preferred over a FOR...N are two vari 10... LOOP. 1, DO WHILE...LOOP 2, DO UNTIL...LOOP DOWHILE_LOOPUntitled WHILE...LOOP Example 4: To display odd m 1.52 Step-by-step description of the DO incremented to 3. Toop ends. | 1 y 1 Example 2: To add numbers ‘The above loop is executed as long as the value of A is less than 3, Ifthe condition in the DO WHILE... LOOP is not true, the loop is notes atall. Consider the following example.example 4: To display odd numbers less than 30, a0 PRINT “The sum of numbers =the DO UNTI the condition is false. L... LOOP is: The general form a set of statements to be executed ‘The loop comprising a set of Let us look at an example of this loop. ‘The output of this progany Fe 5.12 Oups ‘The above loop is executed as long as the condition A>3 is false or asl} os -ay> > Ais less than or equal to 3. . Table 53 Step-by-step description of the DO UNTIL...LOOP EXITING Leer For this, you use the E! EXIT DO statement in t The following program loop ends if the value ofPree Giunye ete aleatae he only ditfene Of he false or as longa2, The default value ofthe step va at no 4) a posithe value Words to Know 1 5 + Loop: Ris usedtorepeet te execution of a group af statements many times. ] 6. What wil be the oxtput forthe + Loopingstatements are usetto repeat the execution ofa certain setoseenat : imustple bes. . a4 » +, FOR.NEXT and D0. L00P ar wo loping statements in QBASIC. zi : * TheFOR NEM statemest i usecwhenyouknow the umber ofunesseied vet Wirt the value taken by the contro has to be I
You might also like
Chapter4QBasic ProgrammingStatements
PDF
100% (1)
Chapter4QBasic ProgrammingStatements
8 pages
LOOP
PDF
No ratings yet
LOOP
6 pages
CSC301_CHAPTER 6-3
PDF
No ratings yet
CSC301_CHAPTER 6-3
24 pages
The Islamia College of Science & Commerce, Srinagar - J &K: (UGC-Autonomous)
PDF
No ratings yet
The Islamia College of Science & Commerce, Srinagar - J &K: (UGC-Autonomous)
13 pages
Ch-5.2 Loop
PDF
No ratings yet
Ch-5.2 Loop
29 pages
For Loop-Problem Solving and Program m3
PDF
No ratings yet
For Loop-Problem Solving and Program m3
26 pages
CSM 157 PROGRAMMING-Week5
PDF
No ratings yet
CSM 157 PROGRAMMING-Week5
17 pages
If, If Then, Nested If Selection Statements & Loops
PDF
No ratings yet
If, If Then, Nested If Selection Statements & Loops
52 pages
Loops: Pretest Loops Post Test Loops
PDF
No ratings yet
Loops: Pretest Loops Post Test Loops
33 pages
Chapter 4.0
PDF
No ratings yet
Chapter 4.0
55 pages
CSC425 Topic 3 Control Structure II
PDF
No ratings yet
CSC425 Topic 3 Control Structure II
32 pages
Brainware University: (ESCM201) Class Notes (Programming For Problem Solving)
PDF
No ratings yet
Brainware University: (ESCM201) Class Notes (Programming For Problem Solving)
7 pages
Class-8 Ict Ppt Q-basic
PDF
No ratings yet
Class-8 Ict Ppt Q-basic
20 pages
CSC 112 - Lecture 4
PDF
No ratings yet
CSC 112 - Lecture 4
7 pages
5 Loop
PDF
No ratings yet
5 Loop
25 pages
Control Statements (Looping) While-Do While and For
PDF
No ratings yet
Control Statements (Looping) While-Do While and For
27 pages
Iterative Statement D
PDF
No ratings yet
Iterative Statement D
13 pages
Chapter 3 - Flow of Control Part II
PDF
No ratings yet
Chapter 3 - Flow of Control Part II
35 pages
Lesson 6-Repeating
PDF
No ratings yet
Lesson 6-Repeating
13 pages
Arduino - Loop Statement
PDF
No ratings yet
Arduino - Loop Statement
23 pages
Problem Solving Algorithms m3
PDF
No ratings yet
Problem Solving Algorithms m3
35 pages
Decision Making and Looping
PDF
100% (1)
Decision Making and Looping
31 pages
Week 09 (Repetition) (1)
PDF
No ratings yet
Week 09 (Repetition) (1)
62 pages
Chap06 - Looping
PDF
No ratings yet
Chap06 - Looping
51 pages
chapter 2
PDF
No ratings yet
chapter 2
57 pages
Chapter 07 - Looping (Student)
PDF
No ratings yet
Chapter 07 - Looping (Student)
54 pages
05 Loops
PDF
No ratings yet
05 Loops
18 pages
CSE123 Lecture6 2012 PDF
PDF
No ratings yet
CSE123 Lecture6 2012 PDF
21 pages
LM - Unit4 2
PDF
No ratings yet
LM - Unit4 2
8 pages
E Balagurusamy CH 6 Solution
PDF
No ratings yet
E Balagurusamy CH 6 Solution
18 pages
05 Betc 1313 - Lab 3 Repetition Control Tech
PDF
No ratings yet
05 Betc 1313 - Lab 3 Repetition Control Tech
13 pages
Chap4-Loop Statements
PDF
No ratings yet
Chap4-Loop Statements
40 pages
Lecture 3
PDF
No ratings yet
Lecture 3
34 pages
Module5 Loops
PDF
No ratings yet
Module5 Loops
28 pages
Unit 5 - Looping
PDF
No ratings yet
Unit 5 - Looping
19 pages
06 Loop Statements
PDF
No ratings yet
06 Loop Statements
35 pages
MATLAB Guide
PDF
No ratings yet
MATLAB Guide
25 pages
For Loop ES081 PART B
PDF
No ratings yet
For Loop ES081 PART B
21 pages
For Loop: - The Most Popular Looping Instruction - The For Loop Allows Us To Specify Three Things in A Single Line
PDF
No ratings yet
For Loop: - The Most Popular Looping Instruction - The For Loop Allows Us To Specify Three Things in A Single Line
17 pages
6_Loops in C
PDF
No ratings yet
6_Loops in C
33 pages
Chap 6
PDF
No ratings yet
Chap 6
32 pages
'If' Statements, 'For' and 'While' Loops If' Statements
PDF
No ratings yet
'If' Statements, 'For' and 'While' Loops If' Statements
6 pages
Looping
PDF
No ratings yet
Looping
26 pages
Visual Basic Net
PDF
No ratings yet
Visual Basic Net
14 pages
Iterative Statements
PDF
No ratings yet
Iterative Statements
16 pages
Standard Algorithms
PDF
No ratings yet
Standard Algorithms
7 pages
L4-Control Statement in C - Part 2.ppt
PDF
No ratings yet
L4-Control Statement in C - Part 2.ppt
32 pages
Csc211 2023 Class - Iteration
PDF
No ratings yet
Csc211 2023 Class - Iteration
18 pages
Lecture 1 Looping Statements
PDF
No ratings yet
Lecture 1 Looping Statements
84 pages
Chapter 06
PDF
No ratings yet
Chapter 06
48 pages
IT - Looping
PDF
No ratings yet
IT - Looping
11 pages
cc102 Module
PDF
No ratings yet
cc102 Module
80 pages
Unit 4 (C++) - Part Two
PDF
No ratings yet
Unit 4 (C++) - Part Two
54 pages
For..Next Loop - Complete
PDF
No ratings yet
For..Next Loop - Complete
21 pages
Week 05
PDF
No ratings yet
Week 05
45 pages
Cse 122
PDF
No ratings yet
Cse 122
4 pages
Lecture 4 - Iteration Statements
PDF
No ratings yet
Lecture 4 - Iteration Statements
53 pages
Looping / Iterative Statements: While Loop
PDF
No ratings yet
Looping / Iterative Statements: While Loop
7 pages
LOOPS
PDF
No ratings yet
LOOPS
13 pages
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
Chapter4QBasic ProgrammingStatements
PDF
Chapter4QBasic ProgrammingStatements
LOOP
PDF
LOOP
CSC301_CHAPTER 6-3
PDF
CSC301_CHAPTER 6-3
The Islamia College of Science & Commerce, Srinagar - J &K: (UGC-Autonomous)
PDF
The Islamia College of Science & Commerce, Srinagar - J &K: (UGC-Autonomous)
Ch-5.2 Loop
PDF
Ch-5.2 Loop
For Loop-Problem Solving and Program m3
PDF
For Loop-Problem Solving and Program m3
CSM 157 PROGRAMMING-Week5
PDF
CSM 157 PROGRAMMING-Week5
If, If Then, Nested If Selection Statements & Loops
PDF
If, If Then, Nested If Selection Statements & Loops
Loops: Pretest Loops Post Test Loops
PDF
Loops: Pretest Loops Post Test Loops
Chapter 4.0
PDF
Chapter 4.0
CSC425 Topic 3 Control Structure II
PDF
CSC425 Topic 3 Control Structure II
Brainware University: (ESCM201) Class Notes (Programming For Problem Solving)
PDF
Brainware University: (ESCM201) Class Notes (Programming For Problem Solving)
Class-8 Ict Ppt Q-basic
PDF
Class-8 Ict Ppt Q-basic
CSC 112 - Lecture 4
PDF
CSC 112 - Lecture 4
5 Loop
PDF
5 Loop
Control Statements (Looping) While-Do While and For
PDF
Control Statements (Looping) While-Do While and For
Iterative Statement D
PDF
Iterative Statement D
Chapter 3 - Flow of Control Part II
PDF
Chapter 3 - Flow of Control Part II
Lesson 6-Repeating
PDF
Lesson 6-Repeating
Arduino - Loop Statement
PDF
Arduino - Loop Statement
Problem Solving Algorithms m3
PDF
Problem Solving Algorithms m3
Decision Making and Looping
PDF
Decision Making and Looping
Week 09 (Repetition) (1)
PDF
Week 09 (Repetition) (1)
Chap06 - Looping
PDF
Chap06 - Looping
chapter 2
PDF
chapter 2
Chapter 07 - Looping (Student)
PDF
Chapter 07 - Looping (Student)
05 Loops
PDF
05 Loops
CSE123 Lecture6 2012 PDF
PDF
CSE123 Lecture6 2012 PDF
LM - Unit4 2
PDF
LM - Unit4 2
E Balagurusamy CH 6 Solution
PDF
E Balagurusamy CH 6 Solution
05 Betc 1313 - Lab 3 Repetition Control Tech
PDF
05 Betc 1313 - Lab 3 Repetition Control Tech
Chap4-Loop Statements
PDF
Chap4-Loop Statements
Lecture 3
PDF
Lecture 3
Module5 Loops
PDF
Module5 Loops
Unit 5 - Looping
PDF
Unit 5 - Looping
06 Loop Statements
PDF
06 Loop Statements
MATLAB Guide
PDF
MATLAB Guide
For Loop ES081 PART B
PDF
For Loop ES081 PART B
For Loop: - The Most Popular Looping Instruction - The For Loop Allows Us To Specify Three Things in A Single Line
PDF
For Loop: - The Most Popular Looping Instruction - The For Loop Allows Us To Specify Three Things in A Single Line
6_Loops in C
PDF
6_Loops in C
Chap 6
PDF
Chap 6
'If' Statements, 'For' and 'While' Loops If' Statements
PDF
'If' Statements, 'For' and 'While' Loops If' Statements
Looping
PDF
Looping
Visual Basic Net
PDF
Visual Basic Net
Iterative Statements
PDF
Iterative Statements
Standard Algorithms
PDF
Standard Algorithms
L4-Control Statement in C - Part 2.ppt
PDF
L4-Control Statement in C - Part 2.ppt
Csc211 2023 Class - Iteration
PDF
Csc211 2023 Class - Iteration
Lecture 1 Looping Statements
PDF
Lecture 1 Looping Statements
Chapter 06
PDF
Chapter 06
IT - Looping
PDF
IT - Looping
cc102 Module
PDF
cc102 Module
Unit 4 (C++) - Part Two
PDF
Unit 4 (C++) - Part Two
For..Next Loop - Complete
PDF
For..Next Loop - Complete
Week 05
PDF
Week 05
Cse 122
PDF
Cse 122
Lecture 4 - Iteration Statements
PDF
Lecture 4 - Iteration Statements
Looping / Iterative Statements: While Loop
PDF
Looping / Iterative Statements: While Loop
LOOPS
PDF
LOOPS