Computer Science, asked by karthik7775, 10 months ago

palindrome numbers between 1 to 1000 using function int reverse(int n) which returns reverse of n
in java ​

Answers

Answered by Agamsain
1

Answer:

The program will prompt user to input the number and then it will reverse the same number using while loop.

import java.util.Scanner;

class ReverseNumberWhile

{

public static void main(String args[])

{

int num=0;

int reversenum =0;

System.out.println("Input your number and press enter: ");

//This statement will capture the user input

Scanner in = new Scanner(System.in);

//Captured input would be stored in number num

num = in.nextInt();

//While Loop: Logic to find out the reverse number

while( num != 0 )

{

reversenum = reversenum * 10;

reversenum = reversenum + num%10;

num = num/10;

}

System.out.println("Reverse of input number is: "+reversenum);

}

Output:

Input your number and press enter:

145689

Reverse of input number is: 986541

please please mark my answer as brainliest answer.

and also follow me...✔️✔️

thx.... ❤❤❤❤❤

Similar questions