That's a very good video for beginners! :) Really helps. From a teaching standpoint I would include real world examples for those having trouble getting those truth tables. The hole CS50 course is really well thought out. 👍
i just got in a big looping discussion about it and yes he is incorrect in the transcript for this also "if you bear with me for a second. So, I have 4 divided by 13. 4 goes into 13 three times" also for not eng native speakers 4 goes into 13 How many times does 4 go into 13?" is also the same as asking "What (x) do you multiply by 4 to get 13?" We solve the problem with an easy algebra equation: 4(x) = 13 x = 3 The answer on this is rounded to the nearest decimal if necessary. in this case 4*3+1=13 the sign of % do not represent division. Look, X % Y (x modulo y) is very similar not equal to X / Y (x divided by y). 8 / 4 = 2 8 % 4 = 0 (4 goes into 8 twice and there is no remainder) 4 / 8 = 0.5 4 % 8 = 4 (8 goes into 4 zero times because 8 is larger than 4) 12 % 8 = 4 (8 goes into 12 one time and leaves 4 remaining)
This particular video was primarily concerned with arithmetic and boolean operators, and you could shoot an entire video on the ++ and -- operators alone. Each form of the ++ and -- operators has a _result_ and a _side effect_ : - The result of x++ is the current value of x; as a side effect, 1 is added to x - The result of ++x is the current value of x + 1; as a side effect, 1 is added to x The -- operator works the same way, you're just subtracting 1 instead of adding. Important things to remember: The side effect does _not_ have to be applied immediately upon evaluation - in an expression like "x = ++y * 2", the side effect of adding 1 to y does not have to happen immediately; the following is one possible order of evaluation: tmp
C has no operators for strings. C has no actual string datatype - the "string" type provided by the cs50.h header is just an alias for "char *". Strings are sequences of character values including a 0-valued terminator. Strings are stored in arrays of character type. Under most circumstances, an expression of array type "decays" to an expression of pointer type, and the value of the expression is the address of the first element of the array. So most of the time when you're dealing with strings you're dealing with expressions of type "char *", but a "char *" is not a string. Since strings are stored as arrays of character type, the only operators available are the [] subscript operator, the unary * dereference operator, the sizeof operator, and the _Alignof operator; that's it. There's no operator for concatenating, slicing, or otherwise manipulating a string - you have to rely on library functions (or write your own) for that.
if non-zero values evaluate to true, couldn't you get the exact same functionality as a for loop, in a while loop instead? just have the while loops start with "while (i)", and then at the end of each loop just reduce i by 1
@@UzbekCriminal dang you smart. :D I found it weird at first when he would say it like arith-medic but thanks for your explanation. Now I can concentrate on the lesson
No-one comments how caring Doug Lloyd is in his explanations? He is such a joy to listen to!
Thank you to the teacher as well as to Harvard university...
Might be useful to note that on British keyboards, the vertical bar | is next to left shift
wow
Harvard's CS50 ROCKS!!!
Great explanations, better than millions of teachers out there, you can see and feel he cares
SLIDES:
cdn.cs50.net/2017/fall/shorts/operators/operators.pdf
I don't like reading the comments because you guys confuse me with those smart questions
That's a very good video for beginners! :) Really helps. From a teaching standpoint I would include real world examples for those having trouble getting those truth tables. The hole CS50 course is really well thought out. 👍
Love you Harvard 💝
thank you very much for such a great class for me!!!!
wondering what is the etymology/origin of calling ! 'bang'? Did it come out in a certain programming circle?
See en.wikipedia.org/wiki/Exclamation_mark#History and www.catb.org/jargon/html/B/bang.html for some thoughts!
@@davidjmalan god! you guys have explanation for literally, everything ;)
2:36
actually I think you'll find it is 13 divided by 4🤓
i just got in a big looping discussion about it and yes he is incorrect in the transcript for this also "if you bear with me for a second. So, I have 4 divided by 13. 4 goes into 13 three times" also for not eng native speakers 4 goes into 13 How many times does 4 go into 13?" is also the same as asking "What (x) do you multiply by 4 to get 13?" We solve the problem with an easy algebra equation:
4(x) = 13
x = 3
The answer on this is rounded to the nearest decimal if necessary. in this case 4*3+1=13 the sign of % do not represent division.
Look, X % Y (x modulo y) is very similar not equal to X / Y (x divided by y).
8 / 4 = 2
8 % 4 = 0 (4 goes into 8 twice and there is no remainder)
4 / 8 = 0.5
4 % 8 = 4 (8 goes into 4 zero times because 8 is larger than 4)
12 % 8 = 4 (8 goes into 12 one time and leaves 4 remaining)
Anybode wanna cooperate on Lab 1? It seems we are required to cooparate with classmates, but I'm taking the course online.
Why wasn't mentioned in the video about the operators:
++x;
--x;
?
Why x++ is preferred over ++x?
actually its the same but you will see lots of x++ more than ++x
@@mohammednajy3659 they aren't the same, their behavior are slightly different.
This particular video was primarily concerned with arithmetic and boolean operators, and you could shoot an entire video on the ++ and -- operators alone.
Each form of the ++ and -- operators has a _result_ and a _side effect_ :
- The result of x++ is the current value of x; as a side effect, 1 is added to x
- The result of ++x is the current value of x + 1; as a side effect, 1 is added to x
The -- operator works the same way, you're just subtracting 1 instead of adding.
Important things to remember:
The side effect does _not_ have to be applied immediately upon evaluation - in an expression like "x = ++y * 2", the side effect of adding 1 to y does not have to happen immediately; the following is one possible order of evaluation:
tmp
It would be nice to make a video (only) of operators for strings.
In C string variables don't exist. Its only included in cs50.h.
C has no operators for strings. C has no actual string datatype - the "string" type provided by the cs50.h header is just an alias for "char *".
Strings are sequences of character values including a 0-valued terminator. Strings are stored in arrays of character type. Under most circumstances, an expression of array type "decays" to an expression of pointer type, and the value of the expression is the address of the first element of the array. So most of the time when you're dealing with strings you're dealing with expressions of type "char *", but a "char *" is not a string.
Since strings are stored as arrays of character type, the only operators available are the [] subscript operator, the unary * dereference operator, the sizeof operator, and the _Alignof operator; that's it. There's no operator for concatenating, slicing, or otherwise manipulating a string - you have to rely on library functions (or write your own) for that.
if non-zero values evaluate to true, couldn't you get the exact same functionality as a for loop, in a while loop instead?
just have the while loops start with "while (i)", and then at the end of each loop just reduce i by 1
thanku sir
To Harvard University
is x- - still x=1? or x=-1?
you have to define x first. (x = 10; x > 0; x--) starts with x as 10 and keeps counting down by 1 until its 0.
Richard Nolet uh ok thanks so much
x = x - 1
x-=1
x-- is just x-1
Last
Not anymore.
He said "Arithmetic" wrong.
I believe that's how it's pronounced in this case, since it's being used as an adjective rather than a noun.
@@UzbekCriminal dang you smart. :D I found it weird at first when he would say it like arith-medic but thanks for your explanation. Now I can concentrate on the lesson