Learning How To Program - Build a Simple Calculator
February 6, 2023
• 279 views
Learninglearn to codeeducationprogramminghow tohow to codehow to programlearn to programlearn to code for beginnerslearn to code for freefree programmingfree webinarprogramming livelive programmingprogramming live streamcoding livecoding live streambeginner codingbeginner programming tutorialbeginner coding tutorialcoding tutorialprogramming tutorialprogramming for beginnerscoding for beginnerstips for beginner programmers
I'm Nick Cosentino, and I'm a Principal Engineering Manager at Microsoft. I believe that programming is one of the most important skills you can have access to, and I'm here to help you get started.
In our last livestreaming session (https://youtu.be/vWk8CCKVjvo), we got into the very basics of programming. We started talking about "Hello, World!" and variable types.
In this session, we'll kick things up a notch and make it more interesting. We'll build our very own calculator that can add num...
View Transcript
you're not going to need any special software to be able to do this I did put a link in the chat to something called.net fiddle and that's going to let you if you want to follow along On Your Side you can actually write code right in the browser you can try it out so no pressure If you just want to watch and kind of follow along that's cool too but if you want to try it out you don't need to download anything fancy and you'll be able to get going okay so I'm going to go ahead and switch over my video here to the screen share and then if I learned anything from the last stream I'm going to try to get zoomed in a little bit more it doesn't leave a whole lot for us to get on the screen but um that should
be okay for now I think maybe I'll zoom out to about there if you have any concerns about how much visibility you have please just please just mention in the chat and I'll try to zoom out or zoom in depending on how it looks but let's go ahead and dive into it so in.net fiddle we're going to be set up here I have the compiler set to be dot net 4.7.2 don't worry too much about this the reason I have this selected is actually because this particular website has a bit of an issue when we're going to be putting user input in if I pick some of the other versions so you don't have to worry about that but if you're trying it on your side and you're noticing that you're having some issues as we go through this and you're trying it out you
might want to switch your compiler version on the left here to 4.7.2 and hopefully those problems go away okay so what we have on the screen right now is just a really simple program this is like a shell program for C sharp where we have a program class and then we have what's called an entry point that's called Main so you don't have to know too much about that um in later versions of C sharp they've actually made this way easier to get started literally the first line of code you write can do something but right now we kind of have this extra stuff that you might have questions about but you don't have to worry because we're going to be writing code in this area right here that I have highlighted so the code that I have written right now is actually just a
bunch of comments and I wanted to put this on the screen to kind of walk us through what we're going to try to build so it's going to be a really really simple calculator it's just going to take two numbers that we're going to let the user input and then we're going to basically take those two numbers add them together write the answer back out to the console so it'll show up on the screen and then we're going to have a loop around the whole thing that lets you enter in another two numbers so on and so forth and that's going to let us practice a couple things in programming and I like this example because regardless of the programming language you want to spend more time learning these concepts are applicable in different programming languages so we're going to be looking at if statements
where we have branching logic we're going to be looking at Loops which are another piece of programming that's going to show up basically in any language you go to touch and then we're also going to have information about the different data types so we're going to be taking user input that is called a string so it'll be text and we're going to have to work with numbers to actually add it together so with that said let's go try implementing this code here so to start we need to be able to let users enter in two numbers so what we can do to start is we can actually tell the user you need to enter your first number and we can do that with console.writeline if you ever go make your first C sharp program usually you'll already have something that says console right line with
hello world inside of it and the text that we want to write out to the console goes in between these two double quotes so we would say enter your first number so when we do this I mean we can go run it right now and you can see that it's just going to print out into your first number and the program's already done so really a simple program right now we need to do a little bit more so if right line puts some text onto the screen how do we get the user input from the user to store in our program well the opposite of right line is going to be read line so let's go ahead and try that console read line no parameters and if I run this now you can see we get this little character here and we can actually go
type something in here so I could type in um one two three and then the program's done so it's the first part of the calculator trying to get some of this input but we're not actually doing anything with it so okay if I typed in the number one two three the next thing we want to do is actually be able to take that user input and save it somewhere so that we can use it in our calculator because the way the code's written right now once we get that user input the program just ends so we're not actually doing any math yet that's okay so the the read line result is something we're going to want to store into a string variable because read line gives us a string back so we can make a string variable we'll call it input 1 like this and
again if I run this and type 1 2 3 here the program still ends it doesn't do anything but what you can't see just from running it like this is that at least the number or the string one two three went into this variable so that's actually cool we have that stored in our program now so every time we go to run this and we type in some input that's going to get saved into input 1. so what's interesting here is that we have basically two numbers that we want to add together so if this is how we get one number how do we get the second one well we can actually just go ahead and copy and paste that code and then we can say enter your second number oops I have to be able to type properly and we'll put input 2 here
so a small adjustment right we have the input 1 and input 2 and we're writing to the console your first number and second number let's go ahead and run the program so we can say the first number is one one one let's say and now we can see it's saying enter your second number okay so 222 is our second number head on the program completes so at this point we have stored two numbers in our program when we run it but we're still not doing anything with it so when we're working with a calculator the first thing you might be thinking is okay well we said this calculator is going to add two numbers together so if we have both numbers stored here wouldn't we want to just say input 1 plus input 2 and then we could go right that to the console so
we can try that right so we could say answer so we'll go calculate the answer we'll add them together and then we're going to write the result and we can say something like answer and then I'm going to write another line out that actually just puts the answer so the first part is just basically to to write some extra text that says basically this is going to be the answer and then we write the actual answer so what happens when we go and run this now so we can enter our first number great now we can enter a second number and then it should add them together but wait a second one one one plus two two two should be 333 what happened here why did we get 1 1 and then two two right after it Why didn't it add these two numbers together
well the reason for that is actually because the input from the console is actually a string and if you're not familiar with programming We have basically different data types that we can store our variables as and a plus operator in the language C sharp between two strings actually does concatenation so it will join both strings together so that's why we see one one one then two two that's actually not what we want to have happen here we need to somehow make these numbers so that we can get a number added together and write that to the console so we can actually fix this by trying to take the input that's a string right input 1 is a string and input two is a string we can go try to convert this into an integer so what we're not going to start with is any type
of error checking for now let's assume that in our calculator when we go to type in numbers they will be numbers if we have time at the end of this we can try to do some error checking and if we don't have time that's something that maybe you can try experimenting with on your own time and seeing if you can validate the user input okay so we need to go from string to integer there's a couple of different ways to do this but we're actually going to use the parse method so what we can do is say int number one so we're going to declare a variable called number one and the type of it is an integer then what we're going to do is say int dot parse and then we're going to pass in input 1. okay so what this line of code
does on line 16 just to highlight it here what this line is going to do for us is take this string value it's going to call the parse method on it which is a built-in method in net that we have access to that's going to take care of taking the string so the text in our example that was one one one and it's actually going to parse it and see if it's a number and then store it as a number so like I said we're not doing error checking right now so if you typed the word giraffe it is as the first number it will blow up it will throw an exception it's not going to work your program will crash so if we have time we'll come back to that so that's how we get the first number now if we want to get
the second number it's going to look very similar I just copy the line I'm going to paste it this is also by the way one of the most common ways that you get programming bugs is by copying and pasting stuff and then not updating everything accordingly so I have to be careful here in this live demo but I'm going to put input 2 here as the number or the input we want to parse and change number one to be number two okay great so if all goes as planned we're going to have both of our our text inputs we're going to parse both of those things and have them stored as integers now we can go try to add them together so this line here is wrong what we actually want is we want to declare an integer and we're going to say the the
variable name is answer and the type of it is an integer and then we're going to add our numbers together okay so let's go ahead and see how this behaves instead so before I run this recall that we had one one one followed by 222 which is not what we wanted it actually stuck both of those strings together not good for a calculator we need these numbers to actually add okay so how do we do that well let's try running it enter your first number one one one the second number so far so good and the answer is 333 which is great so the difference if we look back at line 23 and 24 is that your input was a string type and now we've changed that to be integer base so we can add integers and then we have actual bath happen instead of
adding strings together which is called concatenation okay great so we've actually built the very basics of a calculator but I said we were going to look at loops and we were going to look at if statements so there's a couple of things that I want to introduce for us that are going to allow us to use loops and if statements so let's go ahead and try putting a loop in place so what I'm thinking there's a bunch of different ways that you can write Loops in different languages and even in C sharp there's a handful of different ways you have something called a for Loop and four Loops generally let you count so you would start at some number and then you would be able to continue from that number to the next to the next and then you have some limit that you want
to count up to it's really handy if you have say something that you want to you know start at one point and get to another you know how many times that you want to execute the loop so that's a really good um you know mechanism for looping on things there's another type of loop that's called a for each Loop and basically that will allow you to walk through a group of things one at a time and so as the name suggests for each one of these things that is in a collection of sorts then you're able to run some code for each one of those things in this particular case I want to use something called a while loop and a while loop is something that will let you continue running the body of the loop so all of the code that goes inside of
this Loop will continue to run while a condition is true so the way that looks is you would type while and then your condition would go here and then all of the stuff that's in here is the part that would Loop over and over so there's a bit of a tricky thing going on here though because if you were to do something like this and we go to run this code it's actually don't run this by the way um this will actually basically run your program for forever and not do anything it's because there's nothing inside of the loop it's just a comment and this condition says run this Loop while true and the reason this happens is because everything that's between these parentheses when that it's called an expression the part that would go in there when that expression evaluates to true and spoiler
alert the word true is always going to evaluate is true while that expression is true your Loop will keep going so running something like this isn't going to be a good time so we're not going to do it quite like this but I do want to actually use a while true Loop there's a lot of reasons I would recommend against this in general but for this example we're going to go with it so all that I'm going to do is take the rest of our calculator code right I'm going to um can I oh perfect I wanted to see if I could press Tab and it would indent everything and it worked I was scared it might actually erase it but there we go so what I've done now if we look at our code is it's the same calculator code that we wrote I
didn't change anything I just moved it over just so it would visually look better and then I wrapped a loop around the whole thing so that's kind of cool so what's going to happen if we run this so I pressed run enter your first number seven and our second number is five this should come out to 12. good okay my math still works up here now you'll notice that it didn't just finish instead it says enter your first number so now our calculator is actually something that can run over and over again so cool let me uh nine is the first number and uh we'll do six so this should come out to 15. great so it's not super exciting but you can see that we have the pieces the the basic fundamental pieces of a calculator going on here so now what happens when
we want our calculator to finish right because it can't finish it's as we said when you have a wild true here your Loop is going to run for forever there is nothing that will let this Loop stop running so currently our program does not have a way to exit we can do better than that so we will and before I do what I'm just going to do for fun is show you that our error handling doesn't work so if I were to say zebra is the first number what's going to happen we get this runtime exception all this nasty printout right here to the console and this is basically telling us you can see it tells you the error right input string zebra in this case was not in the correct format so if we look at line 18 this is where we had the
parse method so of course the word zebra is not a number it cannot be parsed so our program actually crashes conveniently when we crash the program it stopped running so now that it's stopped running let's go ahead and make the necessary changes to this so that we can leave the loop when we want to there's a couple different ways we can do this and really if you're making your own calculator following along you could change your mind about how you want to do this I'm just going to show you a simple way I think so you could do something like you know type type exit if you just wanted to exit I'm going to say if you leave the input blank though so if you just press enter instead of entering a number that's going to exit the calculator for us so this is where
we're going to look at if statements and what we're able to do is say if some condition is true then we're going to have a body of code that follows that will run only when the condition is true so that will look like this if input 1 equals and when we're doing a comparison in C sharp it's a double equal sign so if you're new to programming this might look a little bit weird but just to explain the single equal sign this means that we're taking whatever's on the right side of the equal sign and putting the result into the left side when you have a double equal sign what it's doing is going to compare what's on the left and what's on the right and if that evaluates to being true so if they are equal then it's going to in this case that'll
evaluate to true and then we'll run the if statement so I said just for this example I want to say if the input's blank this is going to be us exiting the calculator so we put our curly braces in here and how do we exit well we can just go ahead and break out of the loop break is a keyword you can see that it came up in this special blue color here the break keyword allows us to exit the loop there's another keyword you could use here called return in this case will also exit the loop but it will basically I'm just going to scroll up a little bit higher if you were to hit this line that says return as your code is running it will also exit this entire function that we're inside of so for a particular example that might be
totally fine you could break out of the loop or you could return it of the entire function and end your program in either case so if I break out of the loop only right what it's going to do is say great that means I have to jump outside of this Loop and where is the end of the loop well it's right here so what other code is here nothing so there's nothing there it will exit the loop and just finish the program on its own anyway cool so this is validating input one like I said we're going to have an if statement it's going to check if input 1 compare it with the double equal sign to an empty string so a quote a double quote followed by just another double quote means that there's nothing between the quotes So it's empty usually I would
use some other mechanisms to check for emptiness are a little bit safer but for the example here this is totally fine and like we've been doing we can just go ahead and copy and paste this for the other number right so just so I don't mess up we need to put a 2 here and what this should let us do is actually when we run the program if I said I want my first number to be six and then I said you know what I don't want to run the calculator anymore I could press enter and you'll see that it is not asking me for another number it's not printing the answer anywhere either it's just done so maybe that's not obvious enough what we could do is add a little bit more to our calculator we could say at the very beginning of the
calculator welcome this calculator calculator it's surprisingly hard to spell things when you're trying to like code live and also speak it's kind of bizarre but this calculator will add two numbers together and I should be more clear it's not just two numbers to integers together we don't have any error checking right now so when we run our calculator it's going to say that at the beginning and what we could do is at the very end of the calculator we could say thanks for using our calculator awesome okay so let's go ahead and run this it's not functionally any different it's just that it has a welcome message and then a message at the end when the calculator is done running so I pressed run you can see welcome this calculator will add two integers together then enter your first number excellent I want eight and
then I'm going to add one to eight the answer is nine great now I'm like okay well I only really wanted to add those two numbers together I'm all done here I can just press enter to exit and thanks for using our calculator so cool stuff I wanted to be able to illustrate to you though what happens if I change break to return so I'm gonna go ahead and change break here and I'm going to change it here as well and I just want you to have a quick look before I run this again and I'm going to try to repeat the same exercise but we're going to add eight and one together and then I'm going to press enter after all of that with an empty input and we'll see what happens so remember what this looks like with the welcome message we have
the the line at the bottom that says thanks for using the calculator when I run this we still get the welcome message I'm going to add eight I'm gonna add one we get nine now I'm going to press enter again with no input so the calculator should exit and you'll notice that this time maybe you didn't notice but if you if I point it out you'll see that it did not print this last line here that's because when we hit these returns it actually just exits the entire function like I pointed out before and actually what's really cool is and this is a great part about programming in general you're generally not writing code into like a program like notepad or something or it's not like you're writing code into like Microsoft Word you have a lot of different tools that can give you information
about the code you're writing as you write it so that's a really powerful thing that we can lean on as programmers and in this particular case you'll actually notice that this was smart enough to tell us that this code is unreachable so in fact the way that we have this code written this line of code can never be executed ever and it's because it knows that while we have a while true Loop here the only two ways that you could ever get out of this while true Loop are this return and this return and when you run those return statements it will skip right out of the function and it will never run this so that's kind of neat so I'm going to go ahead and put that back to be break I'm going to change this back to the break and to be honest
with you at this point I think we've actually completed most of what we needed to do for the calculator so I think we still have some time to go try looking at some error checking I'm going to take a moment to pause remind people that have joined the stream because I've seen there's people coming and going which is great um Feel Free at this point you know ask questions in the chat let me know if you can't hear me at all because the last live stream I did people couldn't hear me for a bit uh if you have any questions so far about where we're at on here would love to take a second to try and answer anything for you and otherwise I'm going to keep going but I will periodically try to look over so don't feel nervous to ask anything again this
is totally meant for beginners so there's no such thing as a dumb question I can guarantee you if you have a question someone else is wondering the exact same thing so nothing to worry about okay so nothing's coming in yet and I'm going to continue on to the final step that I think should be pretty easy for us to do but it's all going to center around our input checking so let's go ahead and just run this and we saw earlier that because like when I put in simple numbers like you know one like one two three whatever it all works when I typed in the word zebra of course it didn't work because zebra is not a number and that all basically comes back to this line here this line here does not have any graceful checking of Errors for us it basically will
say if your string that you're inputting here is not an integer it will just blow up it will stop your program it will throw an exception for if you're not familiar with programming generally when we have exceptions being thrown it terminates your whole program it's not a good feeling especially when you don't know where it's coming from but in this particular case we can actually do something here to make it not throw exceptions so for example it only adds integers together I showed you typing zebra earlier but what if I said like 12.5 I want to add 12.5 and the number 6 together well 12.5 is also not an integer it's a floating Point number and floating Point numbers or double Precision floating Point numbers cannot be assigned to integer values if you're not familiar with some of these things that's okay it's just that
in C sharp it's not just a variable type that is number it's specific types of numbers so either you're dealing with integers so whole numbers like 1 2 3 no decimal places or you're dealing with floating Point numbers which allow you to have decimals because we're only adding integers that's not going to fly for us so there's another method that we can actually use here and it's not just parse it's pretty handy it's called tripars and what tri-parse lets us do I'll give you one guess it will try to parse the input and actually lets us make a decision without throwing an exception so if the input itself does not parse to an integer we have an opportunity to do something else now the way that this method is going to look when we try to ask it to parse it might look a little
bit weird because so far we've looked at some pretty basic things and some of uh the next thing that I'm going to write here is is maybe going to look a little bit odd but give me one moment and I'll try to demonstrate so I'm going to get rid of this because and I'm not sure if it's going to show us here oh it does great um although this is arguably too much stuff um it looks a lot cleaner in the program that I use on my desktop but the way that this method works for us is that we're actually able to it doesn't show you properly if you look at the second part here this is string s and then int result there's actually a word missing here when we're using.net fiddle and it's the word out and this is why I was saying
this might be a little bit confusing but I'm going to type this literally the word out and then we're going to have int number one so you'll notice that I kind of let this settle for a second it made all the errors go away this is actually valid code right now and just to explain what this line of code does is it will try to parse this input string and it will output the number into this variable but it only does this if it works so something else that this method does is instead of returning like we had before instead of returning the number it outputs it but it returns a true or a false so if it could parse it if it tried to parse it and it worked we get the number out and then it will return a true for us so
we can actually take advantage of if statements here again and we could say if we tried to parse this then we do something so this now reads if we try to parse input one output that result into the number one variable and then it will this whole part that I have highlighted will evaluate to true because try to parse succeeded and then we would go into this if statement but what I'm going to do here is change this slightly because I'm not necessarily interested in us uh like I'm trying to do some error handling so when it works I just wanted to keep going when it doesn't work I want to do something special so there's another little thing that we can look at and it's basically called the not operator sounds kind of funny but we're just going to invert we're going to invert
this if statement and it's just an exclamation mark right at the beginning just like that so when that's in here at the very start this whole thing is Now inverted so it means when we try to parse and it works yes we will get the number one filled out with the right integer but now this part is going to be true and then this little exclamation mark right in the beginning inverts it and says nope it's false so we've effectively added some error handling on the first input so what do we want to do when we don't get an integer and this is a cool part when you're programming stuff because you get to make this decision we could like we didn't want it to throw an exception before that's what it was doing it was just ending the program we could write a message
and say hey user that's not an integer and then we could end the program we could say hey user that's not an integer and then we could start over and maybe that's a good point we can actually go right back to the top of this Loop and say Hey look you entered something that's totally not an integer we can't add those together so we're just going to let you try the whole thing again that's easy enough to do actually and it's going to show us one more special keyword so first thing we're going to do is tell the user hey that's not an integer okay and then that just tells them it's not an integer it doesn't actually prevent anything from happening it would still not work so we actually need to use this keyword here oops continue There we go continue you can see
is another one of these blue keywords and what continue does is if you're thinking about a loop break was something that got us out of the loop continue just sends us back to the top of the loop which is super handy in this case right because we say if we try to parse this and the result is not true right so if it fails then we're going to say hey that's not an integer and then we're going to say continue so it goes right back to the top of the loop so let's go ahead and do what we did before because we have two inputs I'm just going to copy and paste it and I'm going to overwrite the other code we had here before for parsing the second number now I gotta pay attention again so I don't make typos but we need number
two being output here and we want to parse input to okay so based on this code that I've pasted here it's in both spots this should be error checking for us and if I go ahead and run this now oops I missed something oh no on line 25 you know what this might not like it in.net fiddle let's go ahead this is always going to be something that happens when you're coding live so give me one sec I'm going to try to split this out and do a couple lines here so I'm going to say cool um is valid and we'll do this so this is a little bit more verbose now so it will try to parse input one it will and I actually Wonder too maybe um dot net fiddle doesn't like this all being combined into one line so I'm going to
split that out as well you can see it's kind of funny that it's not actually um the editor doesn't complain until I go to run it so something's a little bit fishy there so let's see if this is happier now I'm gonna go put this on the other spot as well of course this was going to happen when I was demoing it though right so that's okay this is again I would not usually recommend just copying and pasting code like this and trying to update it but let's see what happens okay so there's something about um.net fiddle not liking the syntax that I used I'm quite confident that what I type there actually works in the usual editor that most of us use for developing c-sharp code it's called Visual Studio so usually c-sharp developers are not writing code in their browser like this but
we use a program called Visual Studio that syntax should have been accurate but anyway that's okay if we look at what we have written here I'll just explain it one more time because I did have to kind of change that on the Fly all that I've done was I declared the variable ahead of time so this line of code literally doesn't execute anything for us we're just saying I want a variable that's called number two and it's an integer that's all it does the next part this is still the parsing part that we had before so that hasn't changed but what I'm doing is assigning whether or not that parse was successful into what's called a Boolean variable and a Boolean variable I know it says Bool but like the word is Boolean it's a short form for it so a Boolean variable can only
be true or false which is Handy that's exactly what we want and then you'll you'll notice as well that I kept this exclamation mark in because if you read literally try to read the code like as it's written from like an English perspective it does say if not is valid right so if it's not valid then go do this so let's see if it works now I'm going to put in a number that is valid so 11 is an integer great so I'm going to scroll up just a little bit this means that it was able to parse the first number otherwise we would have seen this show up in the console because we didn't see this it's valid okay but what about the second number let's try putting zebra back into here what's going to happen hey look that's not an integer and we're
right back at the beginning it's like I can't add that so no you did the wrong thing let's try it all over again so enter your first number well okay zebra is not a valid number but um 13.27 how about that nope that's also not an integer so now we seem pretty protected from having actually valid integers so let's try 20. and seven and there we go we have the answer printed out as 27 so the normal use case of just adding integers still works we did get the validation for Strings that are not integers and then floating Point numbers so those numbers of decimals that are also not integers that still works and how did we say we want to exit well if we leave it empty and I press enter thanks for using our calculator so that's been about just over 40 minutes
hopefully this was a good little intro to writing a little calculator we got to cover a couple of really fundamental programming Concepts that while I'm showing you here in C sharp I just I want you to keep this in mind that the concepts here are not strictly for C sharp these are things that if you were like hey I want to go Learn Python I want to go learn JavaScript surprise you are going to have loops in all of these languages they might look a little bit different but you'll have loops you're going to have if statements you're going to have data types JavaScript is a little bit weird but anyway if you go if you go learn JavaScript maybe you'll you'll go learn typescript instead and then you get some of those types but anyway these concepts are applicable across different programming languages and
I hope that as you kind of walk through this with me the takeaway that you have is not super focused on like well why is there a curly brace here why you know why is it indented like that why isn't it like I don't know like why is doesn't it look like this that looks terrible um don't do that it just makes it hard to read you know like why isn't every line starting like this like all these little things like why is there a semicolon at the end of every line these are things that are specific to C sharp if you're trying to learn C sharp it's just going to take practice to to really know and understand and uh make a habit of putting semicolons at the end of lines because believe me it's a little bit odd as a programmer and C
sharp at least semicolons are a character we type all the time and if you're not a programmer you probably never find yourself using a semicolon but the point is that all of these Concepts I hope the takeaway that you got from this is that you can think about how you might apply this to either c-sharp if you're learning C sharp or to another programming language if you're trying to learn something else so that should be it I will probably try and find a way to save this dot net fiddle and then I can put it into the chat actually and then that way if you felt like hey I got kind of lost um you're like watching the recording or something and you're like trying to pause the video and all that I should be able to save this share it to the chat and
then that way if you're just getting stuck you can open this up you can play around with it and hopefully that will help so I think that's it for today thanks so much for watching if uh you know if you're watching it on a recording if you have any comments or sorry questions please ask them in the comments happy to try and answer and yeah I think that's it so thanks again and we'll try to do another one of these in the future we'll see you later
Frequently Asked Questions
Do I need to download any special software to follow along with the calculator tutorial?
No, you don't need to download anything fancy! You can use a website called .NET Fiddle to write and run your code right in the browser.
What should I do if I encounter issues with user input while coding the calculator?
If you're having issues with user input, try switching the compiler version in .NET Fiddle to 4.7.2. This version helps avoid some common problems with user input.
How can I exit the calculator program once I'm done using it?
These FAQs were generated by AI from the video transcript.You can exit the calculator by simply pressing enter without typing anything. This will break the loop and end the program.
