import java.util.Scanner; public class Addingdigit { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("print the number"); int m = sc.nextInt(); // System.out.println("print the floating point number"); // float f = sc.nextFloat(); // int data =1546789; int add = 0; // float fadd =0.0f; while (m != 0) { add = add + m % 10; m = m / 10; /* * fadd = fadd + f%10; f=f/10; * */ } // int length=String.valueOf(1546789).length(); System.out.println(add); // System.out.println(fadd); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)