Arrays and nested for loop not working properly | Sololearn: Learn to code for FREE!

0

Arrays and nested for loop not working properly

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

12/11/2020 4:02:27 PM

Anas kayani

9 Answers

New Answer

+3

The variable "n " in the for loop is not declared and initialized ...

+2

It might be problem with the Scope so declare i globally ...

+1

you should format your code a little better. it's hard to follow. I got the following output from the input: 0 501 1 1001 Press 0 to open salary account Salary account opened Deposit money atleast 500PKR in your salary account Amount of 501 only is added to your salary account Money in salary account in next 5 months respectively month 4 money 501 month 4 money 501 month 5 money 501 month 4 money 501 month 5 money 501 month 6 money 501 Press 1 to open a savings account Savings account opened Deposit money atleast 1000PKR in your savings account Money in savings account in next 5 months respectively 1021 month 4money10211041 month 4money10411061 month 5money10611081 month 4money10811101 month 5money11011121 month 6money11211141 month 4money11411161 month 5money11611181 month 6money11811201 month 7money12011221 month 4money12211241 month 5money12411261 month 6money12611281 month 7money12811301 month 8money1301 // not sure why you made it so complicated. https://code.sololearn.com/ca13a5A12a17

0

If we replace n by i

0

Still loop is not giving regular sequence output

0

No i have tried but still same issue

0

I want the array to proceed once

0

Like 4 5 6 7 8

0

And money should be like 1021 1041 1061 1081 1101 Thats all