Home >Backend Development >C++ >CS#s Introduction to Computer Science - Week Notes

CS#s Introduction to Computer Science - Week Notes

DDD
DDDOriginal
2024-11-11 03:17:02437browse

CS#s Introduction to Computer Science - Week  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

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

The above is the detailed content of CS#s Introduction to Computer Science - Week Notes. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn