Problem Statement :
Subscribe the channel : click here
Q--> Write a program to take a number as input and find that if square number, then last digit of the number is equal to same as input number .
Approach :
1. Take a Integer as input
2. Square the number
3. and check the condition
Code :
import java.util.*;
public class JAVA36 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int sqr=n*n;
int d=sqr%10;
if(d==n){
System.out.println("Correct Number !");
}
else{
System.out.println("Incorrect number !");
}
}
}
Comments
Post a Comment