Guess
Skills:
AI Pair Programming80%
Key Takeaways
Carter debugs a guessing game using debug50
Full Transcript
welcome everyone my name is carter and today i'm going to show you my guessing game and how we can use debug 50 to help figure out what's wrong with it so here i'm trying to write a guessing game that's from the spirit of elementary school game where you would guess a number and someone would tell you it's right or wrong and i called my program guess so i can run it in the terminal with dot slash guess here i go dot slash guess hit enter and i have to guess a number so here i might guess maybe two and hit enter but then i get this flood of messages in terminal and i'm wondering well what's wrong with this why am i getting so many messages here and to try to figure that out i can go into my code with code guest.c and then i can see well i'm not entirely sure what might be wrong here so i need to pause my code at some point and for that i can use a breakpoint so let me go ahead and go to this left side of my guest.c file where i see these red sort of circles pop up i can click on one of them to turn it bright red and at that point i've set a pause point in my code and i can use debug 50 to go in and actually step through my code and see what's going on in there so let me go ahead and type debug 50 of guess hit enter so now that i have my code opened up in debug 50 i can see a few different things i can see that my number variable is currently set to zero and my guess is currently set to this odd 32764 but as i go through my code i'll actually see those numbers sort of fall into place so if i use this step over button to sort of walk to the next line of my code i can see that number becomes five as i expect it to on line six and then as i go to line eight and step over that i get prompted for what's my guess and at that point i might type well three again and i'll hit enter and then i see guess becomes three so now i'm wondering well if my guess is wrong and you know my number is five my guess is three shouldn't i only get wrong guess just once so i'll actually just keep walking through my code with step over and i'll see i'm printing wrong guess which seems right and now i should just exit the program that should be it but i really see that my line in that yellow highlight is going back up to 10 line 10 there and it's actually continuing to go through and print wrong guess and so at this point i can actually see that maybe the bug in my code is i shouldn't have used a while loop i should have maybe used an if statement where i'm only checking for this condition once so now that my while loop has changed to an if statement i should be able to recompile my code and see what's changed so i can use make guess and then i'll run my code guess and when i guess three i guess i should get wrong guess so i'll do three and then i'll get wrong guess but also you're correct and at this point there's probably another bug in my code and so i'll actually leave this one up to you to use debug 50 and see well why am i getting both wrong guess and you're correct
Original Description
***
This is CS50, Harvard University's introduction to the intellectual enterprises of computer science and the art of programming.
***
HOW TO SUBSCRIBE
http://www.youtube.com/subscription_center?add_user=cs50tv
HOW TO TAKE CS50
edX: https://cs50.edx.org/
Harvard Extension School: https://cs50.harvard.edu/extension
Harvard Summer School: https://cs50.harvard.edu/summer
OpenCourseWare: https://cs50.harvard.edu/x
HOW TO JOIN CS50 COMMUNITIES
Discord: https://discord.gg/T8QZqRx
Ed: https://cs50.harvard.edu/x/ed
Facebook Group: https://www.facebook.com/groups/cs50/
Faceboook Page: https://www.facebook.com/cs50/
GitHub: https://github.com/cs50
Gitter: https://gitter.im/cs50/x
Instagram: https://instagram.com/cs50
LinkedIn Group: https://www.linkedin.com/groups/7437240/
LinkedIn Page: https://www.linkedin.com/school/cs50/
Reddit: https://www.reddit.com/r/cs50/
Quora: https://www.quora.com/topic/CS50
Slack: https://cs50.edx.org/slack
Snapchat: https://www.snapchat.com/add/cs50
Twitter: https://twitter.com/cs50
YouTube: http://www.youtube.com/cs50
HOW TO FOLLOW DAVID J. MALAN
Facebook: https://www.facebook.com/dmalan
GitHub: https://github.com/dmalan
Instagram: https://www.instagram.com/davidjmalan/
LinkedIn: https://www.linkedin.com/in/malan/
Quora: https://www.quora.com/profile/David-J-Malan
Twitter: https://twitter.com/davidjmalan
***
CS50 SHOP
https://cs50.harvardshop.com/
***
LICENSE
CC BY-NC-SA 4.0
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
https://creativecommons.org/licenses/by-nc-sa/4.0/
David J. Malan
https://cs.harvard.edu/malan
malan@harvard.edu
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from CS50 · CS50 · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Hello, World: Hadi Partovi
CS50
Content Distribution and Archival in a Digital Age
CS50
CS50 2014 - Week 1
CS50
CS50 2014 - Week 3
CS50
CS50 2014 - Week 0, continued
CS50
CS50 2014 - Week 4
CS50
Week 3, continued
CS50
Quiz 0 Review
CS50
CS50 2014 - Week 3, continued
CS50
CS50 2014 - Week 7
CS50
CS50 2014 - Week 7, continued
CS50
Breaking Through The (Google) Glass Ceiling by Christopher Bartholomew
CS50
Introduction to Amazon Web Services by Leo Zhadanovsky
CS50
CS50 2014 - Week 9
CS50
How to Build Innovative Technologies by Abby Fichtner
CS50
Light Your World (with Hue Bulbs) by Dan Bradley
CS50
Building Dynamic Web Apps with Laravel by Eric Ouyang
CS50
CS50 2014 - CS50 Lecture by Steve Ballmer
CS50
CS50 2014 - Week 10
CS50
This is CS50 with Steve Ballmer?
CS50
Meteor: a better way to build apps by Roger Zurawicki
CS50
Data Analysis in R by Dustin Tran
CS50
Data Visualization and D3 by David Chouinard
CS50
CS50 2014 - Week 6
CS50
Build Tomorrow's Library by Jeffrey Licht
CS50
CS50 2014 - Week 9, continued
CS50
Essential Scale-Out Computing by James Cuff
CS50
iOS App Development with Swift by Dan Armendariz
CS50
Sam Clark Leads Yale Students on Tour to CS50 at Harvard
CS50
3D Modeling and Manufacture by Ansel Duff
CS50
CS50 2014 - Week 5, continued
CS50
hello, world
CS50
CS50 2014 - Deep Thoughts - Hash Table
CS50
CS50 2014 - Deep Thoughts - Binary Tree
CS50
CS50 2014 - Deep Thoughts - Scratch
CS50
CS50 2014 - Deep Thoughts - MySQL
CS50
LaunchCode Visits CS50
CS50
CS50 Live, Episode 100
CS50
CS50 Field Trip to Google
CS50
This is CS50 AP
CS50
Week 4: Monday - CS50 2011 - Harvard University
CS50
Week 2: Wednesday - CS50 2011 - Harvard University
CS50
Week 1: Wednesday - CS50 2011 - Harvard University
CS50
Week 11: Monday - CS50 2011 - Harvard University
CS50
Week 3: Wednesday - CS50 2011 - Harvard University
CS50
Week 12: Monday - CS50 2011 - Harvard University
CS50
Week 1: Friday - CS50 2011 - Harvard University
CS50
Week 3: Monday - CS50 2011 - Harvard University
CS50
Week 10: Wednesday - CS50 2011 - Harvard University
CS50
Week 2: Monday - CS50 2011 - Harvard University
CS50
Week 9: Monday - CS50 2011 - Harvard University
CS50
Week 7: Monday - CS50 2011 - Harvard University
CS50
Week 5: Monday - CS50 2011 - Harvard University
CS50
Week 5: Wednesday - CS50 2011 - Harvard University
CS50
Week 7: Wednesday - CS50 2011 - Harvard University
CS50
Week 8: Monday - CS50 2011 - Harvard University
CS50
Week 9: Wednesday - CS50 2011 - Harvard University
CS50
Week 8: Wednesday - CS50 2011 - Harvard University
CS50
Week 10: Monday - CS50 2011 - Harvard University
CS50
Week 2: Wednesday - CS50 2010 - Harvard University
CS50
More on: AI Pair Programming
View skill →Related Reads
📰
📰
📰
📰
Your AI Knows Everything About React. It Knows Nothing About Your React Project.
Dev.to AI
I Built a Free AI Architect to Stop Spaghetti Code in GitHub Actions
Dev.to AI
Alibaba Bans Employees From Using Claude Code Following Security Concerns
Medium · AI
Cursor Pricing 2026: Free vs Pro vs Ultra — Which Plan?
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI