Coding Issue

I have attached my .ino file pls read it first.

Now the question is that I want to get the value of “price” back from the if/elseif loop to void loop. and in my case I am getting it as 0. I know that it is outside the scope but I am unable to rectify it.

I have mentioned in the code where I need the value.
Answers will be appreciated.

vending_machine.ino (1.37 KB)

DEVDANGI: I have attached my .ino file pls read it first.

"pls" read: Read this before posting a programming question .... [u]FIRST[/u] In particular, note Item #6 about using CODE TAGS.

Use CTRL T to format the sketch.
Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]
        int price = k * 5;

You are creating a new, local, variable named 'price' instead of using the global variable. Change those two to:

        price = k * 5;

I want to get the value of "price" back from the if/elseif loop

The if STATEMENT does NOT cause looping.