>> SPEAKER 1: Let's write a program that prompts the user for int, an integer,
and then does a bit of analysis on it, telling them whether
it's positive or negative.
To do this, let's plan on using the getint function in the CS50 Library,
for which I'm going to need to include cs50.h.
I'm going to anticipate wanting to print some things to
the screen as well.
So I'm also going to include standardio.h.
>> And I'm now going to declare main as usual.
int mainvoid, open curly brace, and preemptively close curly brace.
I'm going to now prompt the user for that int.
Printf, please me an in.
And I'm now going to get that int from the user.
Int, let's call it n, equals getint.
>> In other words, on the right hand side of this expression, I'm going to call
the CS50 function called getint, which is going to do exactly that.
It's then going to return that value from the right hand side of this
expression to the left hand side of this expression, ultimately storing
that value in a variable called n.
Let's now do a bit of analysis.
>> For this, I'm going to employ a condition, or a branch, with if n is,
say, greater than 0, then I'm going to do the following.
Open curly brace and preemptively close curly brace.
I'm going to then print out "you picked a positive integer." /n for
formatting, close quote, closed parenthesis, semicolon.
>> Else, I'm going to want to print something a little different.
So else, open curly brace close curly brace, printf, "you picked a negative
integer." All right, let's save and compile this program.
Make condition zero Enter.
I'm back at my blinking prompt dot slash, condition, zero, Enter.
>> And let's do the simplest of sanity checks first.
One as my int, and I indeed picked a positive integer.
Let's run this program again with condition, zero, Enter, "please give
me an int." Let's try two.
I indeed picked a positive integer.
>> Let's go negative this time.
Dot slash, condition, zero.
Negative 1 and I picked a negative integer.
But I'm not done yet.
Let's try another corner case, if you will.
Let's try zero.
>> Dot slash, condition, zero, Enter, and zero.
And oh boy, I picked a negative integer.
But I'm pretty sure zero is defined as neither positive nor negative.
So I'm going to have to fix this.