0

I want to print number of positive , negative , even ,odd number stored in array by user but I am not getting desired output

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

22nd Apr 2021, 6:27 AM
Harsh Pratap Singh
Harsh Pratap Singh - avatar
2 Respostas
+ 2
Inside the conditionals, you are declaring "count1" etc. as local variables, that, while they have the same name, are different variables than the ones declared in main(), and will shadow them, i.e. inside the conditional, the name "count1" now refers to the newly created local variable, not the one from main(). If you just get rid of the redeclarations and only increment the counters when appropriate, you will get the desired output.
22nd Apr 2021, 7:09 AM
Shadow
Shadow - avatar
+ 1
Thanks I got it
22nd Apr 2021, 8:03 AM
Harsh Pratap Singh
Harsh Pratap Singh - avatar