Program
Program
ALGORITHM:
STEP 1: START
STEP 7: while(temp<0)
STEP 9: Initialize as integer and end=sq%(int)Math.pow(10,c) //determines the last digit of variable sq
SOLUTION:
import java.util.*;
class Automorphic
int x=SC.nextInt();
int sq=(int)Math.pow(x,2);
int temp=x;
int c=0;
while (temp>0)
temp=temp/10;
c++;
int end=sq%(int)Math.pow(10,c);
if (x==end)
System.out.println("Automorphic Number="+x);
else
Algorithm
STEP 1: START
STEP 6: return false; return true; //returns false if the condition is true otherwise returns false
STEP 7: public static Boolean isEmirp(int n) //function to check if the given number is emirp or not
STEP 9: Initialise as integer and int reverse=0 //variable to store the reverse of number
STEP 10: while(n!=0) //executes until the specified condition becomes false
STEP 14: return isPrime(reverse) //user-defined; checks if the reverse number is prime or not
SOLUTION
import java.util.*;
if(n<=1)
return false;
for(int i=2;i<n;i++)
if(n%i==0)
return false;
return true;
if(isPrime(n)==false)
return false;
int reverse=0;
while(n!=0)
int digit=n%10;
reverse=reverse*10+digit;
n=n/10;
return isPrime(reverse);
{
Scanner SC=new Scanner(System.in);
int n=SC.nextInt();
if(isEmirp(n)==true)
else
ALGORITHM
STEP 1: START
SOLUTION
import java.util.*;
class Transpose
{
int row=SC.nextInt();
int column=SC.nextInt();
System.out.println("Enter matrix:");
for(int i=0;i<row;i++)
for(int j=0;j<column;j++)
A[i][j]=SC.nextInt();
System.out.println("Original Matrix");
for(int i=0;i<row;i++)
for(int j=0;j<column;j++)
System.out.print(A[i][j]+" ");
System.out.println(" ");
}
System.out.println("Transpose Matrix:");
for(int i=0;i<row;i++)
for(int j=0;j<column;j++)
System.out.print(A[j][i]+" ");
System.out.println(" ");
ALGORITHM
STEP 1: START
STEP 9: A[I][J]=SC.nestInt()
SOLUTION
import java.util.*;
class Boundary
{
int n=SC.nextInt();
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
A[i][j]=SC.nextInt();
System.out.println("Matrix:");
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
System.out.print(A[i][j]+" ");
System.out.println();
System.out.println("Boundray elemets:");
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
if(i==0||j==0||i==n-1||j==n-1)
System.out.print(A[i][j]+"");
else
System.out.print(" ");
System.out.println();