+ 1
Suppose you have an array like {20,6,40,15,5,7} and then write a java program to get output like {0,1,0,0,0,1}.
Topic-Array
7 Answers
+ 5
for(int i = 0; i < arr.length(); i++){
arr[i] = (arr[i] % 5! = 0);
}
+ 2
Ok, so there is common factor to the numbers who become 0 and those who become 1, the numbers who become 0 are divisable with 5 with no rest and the other numbers divisable with rest, here is my code:
*array name:"arr"*
for(int i=0;i<arr.length;i++)
{
if(arr[i]%5==0)
{
arr[i]=0;
}else{
arr[i]=1;
}
}
+ 1
KfirWe Wrong Answer
+ 1
KfirWe You edit it !
0
Simran Singh Rathore
I compile my answer...
That's correct, check again.
0
Yes, i edit this over 10 minutes ago.
0
Simran Singh Rathore
Never mind, if you like my answer im satisfiedđâ