DEV Community

Dmytro Lobanov
Dmytro Lobanov

Posted on

CS50's Introduction to Computer Science - Week 1 / Notes

https://manual.cs50.io/
Full notes: https://cs50.harvard.edu/x/2024/notes/1/
Practice: https://cs50.harvard.edu/x/2024/psets/1/

To start we should know 3 main keys:

  • how to write commands
  • how to compile commands
  • how to run commands
code filename.c // create a file

// compiles the file from our instructions in C and creates an executable file called
make filename

./filename // run
Enter fullscreen mode Exit fullscreen mode

Building blocks:

  • Functions
  • Variables
  • Conditionals
  • Loops
  • Operators
  • Comments

Types and format codes

Types refer to the possible data that can be stored within a variable. Types are very important because each type has specific limits.
The number of bits limits how high and low we can count.

  • bool, a Boolean expression of either true or false
  • char, a single character like a or 2 and takes 8 bits(1 byte);
  • double, a floating-point value with more digits than a float
  • float, a floating-point value, or real number with a decimal value (32 bits = 4 bytes);
  • int, integers up to a certain size (always 32 bits = 4 bytes), or number of bits
  • long, integers with more bits so that they can count higher than an int
  • string, a string of characters

printf allows for many format codes, full list https://manual.cs50.io/3/fprintf

int     %i
float   %f
char    %c
string  %s
Enter fullscreen mode Exit fullscreen mode

Top comments (0)