text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
of a second.
5,148.89
1.71
But in terms of targeting a missile traveling at mach 5,
5,150.6
3.61
it resulted in a tracking error of over 600 meters.
5,154.21
4.5
It would be a fatal error for the soldiers on what
5,158.71
3.41
happened is a Scud launch was detected by early Warning satellites
5,162.12
6.82
and they knew that the Scud was coming in their general direction.
5,168.94
3.92
They didn't know where it was coming.
5,172.86
2.46
>> -It was now up to the radar component of the Patriot system
5,175.32
2.93
defending Dhahran to locate and keep track of the incoming enemy missile.
5,178.25
4.94
>> -The radar was very smart.
5,183.19
1.419
It would actually track the position of the Scud,
5,184.609
2.041
and then predict where it probably would be the next time the radar sent
5,186.65
3.7
a pulse out.
5,190.35
1.07
That was called a range gate.
5,191.42
1.69
>> -Then, once the Patriot decides enough time has
5,193.11
4.55
passed to go back and check the next location for this detected object,
5,197.66
4.79
it goes back.
5,202.45
1.15
So when it went back to the wrong place, it then sees no object.
5,203.6
5.05
And it decides that there was no object, it was a false detection,
5,208.65
3.51
and drops the track.
5,212.16
1.77
>> -The incoming Scud disappeared from the radar screen.
5,213.93
3.1
And seconds later, it slammed into the barracks.
5,217.03
3.23
The Scud killed 28, and was the last one fired during the first Gulf War.
5,220.26
5.89
>> Tragically, the updated software arrived at Dhahran the following day.
5,226.15
5.81
The software flaw had been fixed, closing
5,231.96
2.97
one chapter in the troubled history of the Patriot missile.
5,234.93
4.876
>> [VIDEO PLAYBACK]
5,239.806
0.923
DAVID J. MALAN: So this is all to say that these issues of overflow
5,240.729
2.791
and imprecision are all too real.
5,243.52
2.34
So how did we get here?
5,245.86
1.06
We began with just talking about printf.
5,246.92
1.975
Again, this function that prints something to the screen,
5,248.895
2.375
and we introduced thereafter a few other functions
5,251.27
2.18
from the so-called CS50's library.
5,253.45
1.495
And we'll continue to see these in due time.
5,254.945
1.965
And we, particularly, used get string, and get int, and now also get float,
5,256.91
3.85
and yet others still will we encounter and use ourselves before long.
5,260.76
3.65
>> But on occasion, have we already seen a need
5,264.41
2.81
to store what those functions hand back?
5,267.22
3.3
They hand us back a string, or an int, or a float.
5,270.52
2.4
And sometimes we need to put that string, or int, or float, somewhere.
5,272.92
3.15
>> And to store those things, recall just like in Scratch, we have variables.
5,276.07
4.03
But unlike in Scratch, in C we have actual types
5,280.1
3.16
of variables-- data types, more generally--
5,283.26
2.27
among them, a string, an int, a float, and these others still.
5,285.53
3.11
>> And so when we declare variables in C, we'll have to declare our data types.
5,288.64
3.681
This is not something we'll have to do later in the semester
5,292.321
2.499
as we transition to other languages.
5,294.82
1.99
But for now, we do need to a priori in advance,
5,296.81
2.8
explain to the computer what type of variable we want it to give us.
5,299.61
4.76
>> Now, meanwhile, to print those kinds of data types,
5,304.37
2.92
we have to tell printf what to expect.
5,307.29
2.28
And we saw percent s for strings, and percent i for integers,
5,309.57
2.88
and a few others already.
5,312.45
1.34
And those are simply requirements for the visual presentation
5,313.79
3.447
of that information.
5,317.237
0.833
>> And each of these can actually be parametrized or tweaked in some way,
5,318.07
4.01
if you want to further control the type of output that you get.
5,322.08
3.29
And, in fact, it turns out that not only is there backslash n for a new line.
5,325.37
4.234
There's something else called backslash r for a carriage return, which
5,329.604
2.916
is more akin to an old school typewriter,
5,332.52
1.84
and also Windows used for many years.
5,334.36
3.33
>> There's backslash t for tabs.
5,337.69
2
Turns out, that if you want to double quote inside of a string,
5,339.69
3.48
recall that we've used double quote double
5,343.17
1.83
quote on the left and the right ends of our strings thus far.
5,345
2.9
That would seem to confuse things.
5,347.9
1.52
>> If you want to put a double quote in the middle of a string-- and, indeed,
5,349.42
3.083
it is confusing to see.
5,352.503
1.167
And so you have to escape, so to speak, a double quote with something
5,353.67
3.45
like, literally, backslash double quote.
5,357.12
1.74
And there's a few other still.
5,358.86
1.37
And we'll see more of those in actual use before long.
5,360.23
4.31
>> So let's now transition from data, and representation,
5,364.54
3.39
and arithmetic operators, all of which gave us some building
5,367.93
2.89
blocks with which to play.
5,370.82
1.25
But now let's actually give us the rest of the vocabulary
5,372.07
2.411
that we already had last week with Scratch
5,374.481
1.749
by taking a look at some other constructs in C-- not all of them.
5,376.23
3.12
But the ideas we're about to see really just
5,379.35
2.33
to emphasize the translation from one language, Scratch, to another, C.
5,381.68
3.93
>> And over time, we'll pick up more tools for our toolkit,
5,385.61
2.86
so to speak, syntactically.
5,388.47
1.35
And, indeed, you'll see that the ideas are now rather familiar from last week.
5,389.82
4.37
So let's do this.
5,394.19
1.01
>> Let's go ahead and whip up a program that actually uses some expressions,
5,395.2
3.67
a Boolean expression.
5,398.87
1.85
Let me go ahead here and create a new file.
5,400.72
2.09
I'll call this condition.c.
5,402.81
3.28
>> Let me go ahead and include the CS50 library.
5,406.09
3.26
And let me go ahead and include standard IO.h for our functions,
5,409.35
3.29
and printf, and more respectively.
5,412.64
2.05
Let me give myself that boilerplate of int main void, whose explanation we'll
5,414.69
4.21
come back to in the future.
5,418.9
1.46
>> Now let me go ahead and give myself an int via get int.
5,420.36
3.46
Then let me go ahead and do this.
5,423.82
2.15
I want to say if i is less-- let's distinguish between positive, negative,
5,425.97
4.18
or zero values.
5,430.15
1.11
>> So if i is less than zero, let me just have this program simply say,
5,431.26
5.37
negative, backslash n, else if i is greater than zero.
5,436.63
5.74