+ 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

10th Sep 2019, 9:00 AM
Simran Singh Rathore
Simran Singh Rathore - avatar
7 Respostas
+ 5
for(int i = 0; i < arr.length(); i++){ arr[i] = (arr[i] % 5! = 0); }
10th Sep 2019, 9:53 AM
Paolo De Nictolis
Paolo De Nictolis - avatar
+ 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; } }
10th Sep 2019, 9:06 AM
KfirWe
KfirWe - avatar
+ 1
KfirWe Wrong Answer
10th Sep 2019, 10:05 AM
Simran Singh Rathore
Simran Singh Rathore - avatar
+ 1
KfirWe You edit it !
10th Sep 2019, 10:10 AM
Simran Singh Rathore
Simran Singh Rathore - avatar
0
Simran Singh Rathore I compile my answer... That's correct, check again.
10th Sep 2019, 10:08 AM
KfirWe
KfirWe - avatar
0
Yes, i edit this over 10 minutes ago.
10th Sep 2019, 10:11 AM
KfirWe
KfirWe - avatar
0
Simran Singh Rathore Never mind, if you like my answer im satisfied😃✋
10th Sep 2019, 10:12 AM
KfirWe
KfirWe - avatar