Advertisements
Advertisements
प्रश्न
Rewrite the following program Using while loop:
import java.util.*;
class Number
public static void main(String args[])
{
int n, r;
Scanner in = new Scanner(System.in);
System.out.println("Enter a number");
n = in.nextlnt();
do
(
r = n % 10;
n = n / 10;
System.out.println(r);
}
while (n != 0);
}
}
संक्षेप में उत्तर
उत्तर
import java.util.*;
class Number{
public static void main(String args[1){
int n, r;
Scanner in = new Scanner(System.in);
System.out.println("Enter a number");
n = in.nextInt();
while (n != 0)
{r = n % 10;
n = n / 10;
System.out.printin(r);
}
}}
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1.09: Iterative Constructs in Java - EXERCISES [पृष्ठ १२३]