cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Using a variable in a loop before it is defined?

StuartBruff
23-Emerald III

Using a variable in a loop before it is defined?

Whilst looking at another worksheet in Mathcad Prime 10, I noticed that an as-yet undefined variable in a loop had a value (albeit zero)

 

2024 09 17 B.png

 

I can't remember if this was standard behaviour in previous versions of Mathcad or not.   However, it certainly caused me some moments of pondering whilst I tried to determine how a variable was initialized in a much longer program (that I was trying to understand in the first place!).

 

Stuart

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:StuartBruff)

The behaviour is the same in MC15 and it seems that any loop does the trick

Werner_E_0-1726575440223.png

 

Werner_E_1-1726575470342.png

 

View solution in original post

1 REPLY 1
Werner_E
25-Diamond I
(To:StuartBruff)

The behaviour is the same in MC15 and it seems that any loop does the trick

Werner_E_0-1726575440223.png

 

Werner_E_1-1726575470342.png

 

Announcements

Top Tags