006-001-012
For Loop: Print Even Numbers
Medium
Problem Description
for loop: Print Even Numbers
In this problem, you will read an integer N from standard input and create a program that uses a step value of 2 in a for loop to print even numbers from 2 to N in order.
Learning Objective: Understand how to modify the step value in for loops for specific patterns
Overview
Create a program that reads an integer N and prints even numbers from 2 to N.
Input Format
N
- N: positive integer (1 ≤ N ≤ 100)
Specifications
- Use a for loop for repetition
- Output only even numbers from 2 to N
- Output each number on a separate line
Sample Input/Output
Input:
10
Output:
2
4
6
8
10
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up