SlideShare a Scribd company logo
1 of 8
Introduction to Loops
QBASIC

RICHA KATHURIA
LOOPS
Let say we want to print the numbers 1 to 100.
What will we do?
Write Qbasic program as:
PRINT 1
PRINT 2
PRINT 3
PRINT 4 ...
UPTO 100
LOOPS

Now that’s a difficult task. We can simplify our work
using loops.

Loops are used when we have repeated work to do ,
with fixed interval.

As in the above example we are repeating the same
command i.e Print and interval between numbers is
one.

Another example can be printing even numbers 1 to
50.Here interval is of two numbers.
for-next Loop
So we can use the loop here to print numbers 1 to 100 as:
for i=1 to 10 step 1
print I
next I
Now let me explain this program.
for i=1 to 100 step 1
Loop variable: a variable on which loop works.
Every loop has three parts:
1. Initial value of loop variable (for i=1)
2. Final value (to 100)
3. The increment step (step 1)
Initial value tells where to start the loop, final value
tells when to stop the loop and
increment step tells how much to increase to get to
next value in loop.
Another example
To print even numbers 1 to 20.
For i=2 to 20 step 2
print i
Next i
Explanation : Here loop variable is “i” , the first even
number is 2, so it is the initial value. Then the final value
is 20 and there a difference of 2 numbers between two
even numbers, hence the step size is 2.
The output:
Thank You

More Related Content

What's hot

Types of Programming Languages
Types of Programming LanguagesTypes of Programming Languages
Types of Programming LanguagesJuhi Bhoyar
 
High level languages representation
High level languages representationHigh level languages representation
High level languages representationgaurav jain
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Md. Imran Hossain Showrov
 
Language translator
Language translatorLanguage translator
Language translatorasmakh89
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and developmentAli Raza
 
Programming Language Evolution
Programming Language EvolutionProgramming Language Evolution
Programming Language EvolutionKushan Dananjaya
 
History of Programming Language
History of Programming LanguageHistory of Programming Language
History of Programming Languagetahria123
 
Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...SHUBHAM PATIDAR FISHERIES ADDAA
 
Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming languageJAIDEVPAUL
 
Computer and its language
Computer and its languageComputer and its language
Computer and its languageAkshitKumar72
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer ProgrammingAllen de Castro
 
Generation of computer languages
Generation of computer languagesGeneration of computer languages
Generation of computer languageskitturashmikittu
 
Generations Of Programming Languages
Generations Of Programming LanguagesGenerations Of Programming Languages
Generations Of Programming Languagespy7rjs
 

What's hot (20)

Types of Programming Languages
Types of Programming LanguagesTypes of Programming Languages
Types of Programming Languages
 
High level languages representation
High level languages representationHigh level languages representation
High level languages representation
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
Language translator
Language translatorLanguage translator
Language translator
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
 
Programming Language Evolution
Programming Language EvolutionProgramming Language Evolution
Programming Language Evolution
 
History of Programming Language
History of Programming LanguageHistory of Programming Language
History of Programming Language
 
Presentation on Programming Languages.
Presentation on Programming Languages.Presentation on Programming Languages.
Presentation on Programming Languages.
 
Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...
 
Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming language
 
operating system
operating system operating system
operating system
 
Computer and its language
Computer and its languageComputer and its language
Computer and its language
 
Ascii codes
Ascii codesAscii codes
Ascii codes
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer Programming
 
Generation of computer languages
Generation of computer languagesGeneration of computer languages
Generation of computer languages
 
Generations Of Programming Languages
Generations Of Programming LanguagesGenerations Of Programming Languages
Generations Of Programming Languages
 
Rajesh ppt
Rajesh pptRajesh ppt
Rajesh ppt
 
Qbasic
QbasicQbasic
Qbasic
 
Qbasic
QbasicQbasic
Qbasic
 

Viewers also liked

Andrew raj, teacher at don bosco, egmore slide share1
Andrew raj, teacher at don bosco, egmore   slide share1Andrew raj, teacher at don bosco, egmore   slide share1
Andrew raj, teacher at don bosco, egmore slide share1rowanalfred
 
Computer (Q BASIC)
Computer (Q BASIC) Computer (Q BASIC)
Computer (Q BASIC) Ujjal Sharma
 
QBASIC
QBASICQBASIC
QBASICnivi88
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorialnhomz
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingMoutaz Haddara
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 

Viewers also liked (10)

Andrew raj, teacher at don bosco, egmore slide share1
Andrew raj, teacher at don bosco, egmore   slide share1Andrew raj, teacher at don bosco, egmore   slide share1
Andrew raj, teacher at don bosco, egmore slide share1
 
Qbtut2.1
Qbtut2.1Qbtut2.1
Qbtut2.1
 
Computer (Q BASIC)
Computer (Q BASIC) Computer (Q BASIC)
Computer (Q BASIC)
 
Qbasic Tutorial
Qbasic TutorialQbasic Tutorial
Qbasic Tutorial
 
Qbasic program
Qbasic programQbasic program
Qbasic program
 
QBASIC
QBASICQBASIC
QBASIC
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorial
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Qbasic tutorial
Qbasic tutorialQbasic tutorial
Qbasic tutorial
 

Similar to Introduction to loops (20)

Python Math Concepts Book
Python Math Concepts BookPython Math Concepts Book
Python Math Concepts Book
 
Notes2
Notes2Notes2
Notes2
 
Loops
LoopsLoops
Loops
 
L06
L06L06
L06
 
Python_Module_2.pdf
Python_Module_2.pdfPython_Module_2.pdf
Python_Module_2.pdf
 
3.2 looping statement
3.2 looping statement3.2 looping statement
3.2 looping statement
 
While loop
While loopWhile loop
While loop
 
Ma3696 lecture 4
Ma3696 lecture 4Ma3696 lecture 4
Ma3696 lecture 4
 
ICP - Lecture 9
ICP - Lecture 9ICP - Lecture 9
ICP - Lecture 9
 
Lesson flow charts 1
Lesson flow charts 1Lesson flow charts 1
Lesson flow charts 1
 
Going loopy - Introduction to Loops.pptx
Going loopy - Introduction to Loops.pptxGoing loopy - Introduction to Loops.pptx
Going loopy - Introduction to Loops.pptx
 
Loops in Python.pptx
Loops in Python.pptxLoops in Python.pptx
Loops in Python.pptx
 
Loops c++
Loops c++Loops c++
Loops c++
 
loops python.pdf
loops python.pdfloops python.pdf
loops python.pdf
 
Loops Do While Arduino Programming Robotics
Loops Do While Arduino Programming  RoboticsLoops Do While Arduino Programming  Robotics
Loops Do While Arduino Programming Robotics
 
Do...Loop
Do...LoopDo...Loop
Do...Loop
 
PYTHON 3.pptx
PYTHON 3.pptxPYTHON 3.pptx
PYTHON 3.pptx
 
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
 
ACM init() Day 3
ACM init() Day 3ACM init() Day 3
ACM init() Day 3
 
Small Basic - Branching and Loop
Small Basic - Branching and LoopSmall Basic - Branching and Loop
Small Basic - Branching and Loop
 

Recently uploaded

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Recently uploaded (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

Introduction to loops

  • 2. LOOPS Let say we want to print the numbers 1 to 100. What will we do? Write Qbasic program as: PRINT 1 PRINT 2 PRINT 3 PRINT 4 ... UPTO 100
  • 3. LOOPS  Now that’s a difficult task. We can simplify our work using loops.  Loops are used when we have repeated work to do , with fixed interval.  As in the above example we are repeating the same command i.e Print and interval between numbers is one.  Another example can be printing even numbers 1 to 50.Here interval is of two numbers.
  • 4. for-next Loop So we can use the loop here to print numbers 1 to 100 as: for i=1 to 10 step 1 print I next I Now let me explain this program.
  • 5. for i=1 to 100 step 1 Loop variable: a variable on which loop works. Every loop has three parts: 1. Initial value of loop variable (for i=1) 2. Final value (to 100) 3. The increment step (step 1) Initial value tells where to start the loop, final value tells when to stop the loop and increment step tells how much to increase to get to next value in loop.
  • 6. Another example To print even numbers 1 to 20. For i=2 to 20 step 2 print i Next i Explanation : Here loop variable is “i” , the first even number is 2, so it is the initial value. Then the final value is 20 and there a difference of 2 numbers between two even numbers, hence the step size is 2.