11.Write a Java program to find first and last digit of a number. Static :- class loop11 { public static void main(String args[]) { int n=1234,ld,ft; ld = n%10; System.out.println("last number :- "+ld); ft = n; while(ft>=10) { ft = ft/10; } System.out.println("First number :- "+ft); } } Output :- Dynamic :- import java.util.*; class loop11 { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n,ld,ft; System.out.println("Enter the number :- "); n=in.nextInt(); ld = n%10; System.out.println("Last Digit :-"+ld); ft=n; while(ft>=10) { ft = ft/10; } System.out.println("First Digit :-"+ft); } } Output :-
All computer course for class 9th to 12th with proper practical and theory .........