Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Basics (Retired) Perform Converting Strings to Integers

Edward Zhou
Edward Zhou
401 Points

why do you need "int runningTotal = 0" in the beginning?

why do you need "int runningTotal = 0" in the beginning? especially when the total is definitely not zero.

2 Answers

Hi, the integer variable must be set otherwise the program won't know where to start from. If you didn't have runningTotal then you wouldn't be able to add up and show the client how many minutes they've worked out for..

It's basically a container to add all the clients minutes and display it.

At the very beginning before anyone adds minutes for the first time, the total IS zero.