Print reverse of a number simple Java programming Code by Naymul Islam PCIU CSE 18

 import java.util.Scanner;


public class ReverseOfNumber {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in); // use for input from user

        int num = sc.nextInt();

        // int num = 10899;


        while (num > 0) {

            int lastDigit = num % 10;

            System.out.print(lastDigit);

            num = num / 10; // n/10;

        }

        System.out.println();

    }

}

import java.util.Scanner;

public class ReverseOfNumber {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in); // use for input from user
        int num = sc.nextInt();
        // int num = 10899;

        while (num > 0) {
            int lastDigit = num % 10;
            System.out.print(lastDigit);
            num = num / 10; // n/10;
        }
        System.out.println();
    }
}


No comments:

Post a Comment

Max Sub Array Sum: Kadane's Algorithm

Code of: Max Sub Array Sum: Kadane's Algorithm. public class MaxSubArraySumKadanesALgorithm {     public static void Kadane ( int ...