[MUSIC] Our next program is to compute the distance of a marathon in yards, so it's, again, a conversion program. Very similar to the program we did where we converted from Fahrenheit to Celsius, but we're going to see a few extra differences. And it's very worthwhile to practice on these programs, because some of the very basic things, you have to get down, that they easily trip you up later on, if you try to do something more complicated. So the idea is, we're going to take in miles and yards, a marathon distance. So you can see it to be 26 miles and 385 yards. And there's a formula, it's kilometers times, roughly, 1.6, times the miles plus the yards, and the yards is divided by 1760. And that's just a conversion formula that we have, to get you to kilometers, and then we'll print. So indeed, if we run this program, I think I precompiled it already. And you see a marathon is 42.185969 kilometers. Now, the program we had just seen with Fahrenheit and Celsius, we kept all in integer, that's a rougher consideration. In this case, we wanted a more accurate answer for the marathon. Otherwise, if we had done it all in integer, we would get something like 42 kilometers. And that might be an interesting exercise, that check, to see what you would do if you did it all as an integer program, see if you would get 42. Now, let's explain some of the ideas we find in this program. This marathon program is taken from A Book on C, by myself and my coauthor, Al Kelley. One of the early programs, just like the Fahrenheit to Celsius program, is an early program in Kernighan and Ritchie. And again, if you want to follow this course, and you want a lot more detail, and lots more exercises, A Book on C is one place that you can get a lot more exposure. So there are some differences with the Fahrenheit to Celsius program. Let's look at what they might be. In that program, we had a declaration, int miles = 26, yards = 385. That's a declaration, with what's called an initializer. So each of those integer variables is given a value, 26 for miles, 385 for yards. Again, that type of statement is a declaration, in the program, we declare the variables we're going to use, we must name them. We want to pick names that are meaningful, because that's good for the documentation of the program. It makes it easier to read and maintain, and easier for other people to use and modify for their own purposes. So miles and yards were identifiers. Int means that that was the data type those identifiers are allowed to use. And recall that on a normal machine, which is typically a 4 byte machine, where an integer is 4 bytes, you can get, roughly, plus and minus 2 billion. So if you go outside that range, something's going to go wrong. But if your program only needs the integers in plus and minus 2 billion, you'll be okay. Now, in some machines, you're allowed to go to [INAUDIBLE], which might even be much larger, and there's even cases where you can go to long long int. But if you need a very large integer range, you have to use special packages. The other key thing to look at in this program is an expression, and that expression, let me get this, it's full screen. That expression, Was kilometers is 1.609 times miles, plus yards, divided by 1760.0. It's very important that we use .0 rather than 1760. And this is one of the key things that can easily trip a non-C programmer up, and certainly a novice. And I didn't write out miles, I didn't write out yards, but I'm condensing this expression and adding parentheses, and those parentheses indicate the order, In which the expressions are done. So the first thing that gets done is 7 divided by 1760. And the reason that we were careful about this, To be a double, is that if we had this as 1760, it would have been an integer divided, but when we make it 1760.0, it's a floating point divided. Now 235 divided by 1760, if 1760 was an integer, the answer would be 0. But since it's a double, you get an appropriate, to something like six significant figures, expression for that value, a fraction. And we didn't want a 0. Now, once this expression is double, and we do this divide, and we get whatever we get, and then we add in miles, the second thing we've done is now add miles to that. And then, finally, we multiply it by 1.609, And that's the third thing that gets done. And that gives us that answer of 42 kilometers and change. So it's very important, in your expressions, to know what domain you're in. By domain, I mean things like integer and double, because that's going to tell you what the arithmetic is being done in, and that arithmetic can affect the meaning of an operator, like divide. Divide can be an integer divide, if everything is integer, or it can be a floating point divided, if one of the arguments is floating point. And then this answer ends up a double. Okay, so this example gives you a number of other ideas to go with the ideas from the Fahrenheit example. And let me give you a suggested, Exercise, Modify the program, To input, Input miles and yards, And then it could be a general, Conversion, much like the Fahrenheit to Celsius, To kilometers. You should be able to readily manage that, having looked at those two programs. [MUSIC]