Previous Next
0 / 15
Module DEMO-33-66DEMO-OOP-33

Print Numbers in Range using for

DEMO-OOP-33 • Object Oriented Programming

Browser-only practice

Problem Statement

Write a C program that asks the user to input 2 integer numbers, then prints all the integers between and including these 2 numbers. You can assume that the first number is less than or equal to the second number.

Your program should read two integers from standard input and output all integers in the range [first_number, second_number] inclusive, each on a new line.

Constraints

-1000 ≤ first_number ≤ second_number ≤ 1000

Input Format

A single line containing two integers separated by a space. The first integer will be less than or equal to the second integer.

Output Format

Print each integer in the range [first_number, second_number] on a separate line.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
1 5
1
2
3
4
5
Sample case showing basic range printing from 1 to 5 inclusive.
Sample #2
Public sample
3 3
3
Sample case where both numbers are the same, so only one number is printed.
Sample #3
Public sample
7 10
7
8
9
10
Sample case showing a small range from 7 to 10 inclusive.
Sample #4
Public sample
-3 3
-3
-2
-1
0
1
2
3
Hidden case testing symmetric range around zero.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings