Explain Counter Controlled Loop program.
Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter5: The Repetition Structure
Section: Chapter Questions
Problem 3RQ
Related questions
Question
Explain Counter Controlled Loop
Expert Solution
Step 1
Counter Controlled Loop:
- A counter controlled loop is also called definite loop because the number of repetitions is called before the loop begins execution.
- Count controlled loop will stop execution after running certain number of times.
- Syntax:
- The count is kept in variable called index or counter.
- If the index reaches the loop bound value then the loop will terminated.
- The following example prints the character and its ASCII value for all lower case characters.
Step 2
Program:
//Defining the class
class Main {
//Defining the main() function
public static void main(String[] args) {
//Counter control loop
for (char x = 'a'; x <= 'z'; x++)
//Printing statement
System.out.println(x + " = " + (int) x);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning