Previous Next
0 / 20
Module DEMO-32-59DEMO-C-32

Reverse 4-Digit Number using for

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a C program that asks the user to enter a 4-digit integer and then prints its digits in reverse order using a loop.

Requirements:

  • Use arithmetic operators / and %.
  • Implement a loop to reverse the digits.

Example:

Input: 1234 Output: Reversed number: 4321

Input Format

The program reads a single line from standard input containing a 4-digit positive integer.

Output Format

The program prints a single line in the format: Reversed number: <reversed_number>

Sample Testcases

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

Sample #1
Public sample
1234
Reversed number: 4321
Basic test case with sample input.
Sample #2
Public sample
5678
Reversed number: 8765
Hidden test case for same logic path.
Sample #3
Public sample
1023
Reversed number: 3201
Test with mixed digits including zero.
Sample #4
Public sample
4056
Reversed number: 6504
Another test with mixed digits including 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