Why this code generated the output (values of n =00301)...?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why this code generated the output (values of n =00301)...??

https://code.sololearn.com/cIv8YBnKCOZD/?ref=app

8th Aug 2020, 5:09 PM
Saumya Mishra
Saumya Mishra - avatar
8 Answers
+ 1
n is element of array, first element has value 1 in 1 2 3 4 1
9th Aug 2020, 7:01 AM
zemiak
+ 2
Alexander Thiem thanks 😇
9th Aug 2020, 6:27 AM
Saumya Mishra
Saumya Mishra - avatar
+ 1
Go step jy step! First of all n is a[0], so n is 1 and a[1] is set to 0 Then n is a[1], so n is 0 and a[0] is set to 0 ..... Do this step by step and you should understand!
8th Aug 2020, 5:31 PM
Alexander Thiem
Alexander Thiem - avatar
+ 1
or add some control prints n=1 a[1] =2 [1, 2, 3, 4, 1] a[1] <-0 n=0 a[0] =1 [1, 0, 3, 4, 1] a[0]<-0 n=3 a[3] =4 [0, 0, 3, 4, 1] a[3]<-0 n=0 a[0]=0 [0, 0, 3, 0, 1] a[0]<-0 n=1 a[1] =0 [0, 0, 3, 0, 1] a[1] <-0
8th Aug 2020, 6:10 PM
zemiak
+ 1
zemiak oh sorry, I forgot the rules. u r right , n is element of array. thanks for help 😊
9th Aug 2020, 12:22 PM
Saumya Mishra
Saumya Mishra - avatar
0
zemiak output prints the value of n .
9th Aug 2020, 6:25 AM
Saumya Mishra
Saumya Mishra - avatar
0
zemiak n is a variable here not an element of array
9th Aug 2020, 7:19 AM
Saumya Mishra
Saumya Mishra - avatar
0
ok, what is value in n ?
9th Aug 2020, 11:49 AM
zemiak