Write down a Java program with array for:
Answers
Answer:
I used java compiler online
Explanation:
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
// Your code here!
int i,div,res;
String inv;
int A1[]=new int[4];
int B1[]=new int[4];
A1[0]=45;
A1[1]=67;
A1[2]=12;
A1[3]=89;
for(i=0;i<=3;i++)
{
System.out.print(A1[i]+" ");
}
for(i=0;i<=3;i++)
{
div=A1[i];
inv="";
while(div > 0)
{
res=div%10;
div=div/10;
inv=inv+res;
}
B1[i]=Integer.parseInt(inv);
}
System.out.println("");
for(i=0;i<=3;i++)
{
System.out.print(B1[i]+" ");
}
}
}