32 bits (4 bytes)
negative: 2^31
positive: 2^31-1 (-1 because to exclude option 0)
a qualifier applied to certain types (int or other data types) that double the positive range of variables of that type at the cost of disallowing negative values
8 bits (1 byte) with negative range -128 and positive range 127
the American Standard Code for Information Interchange (ASCII)
letter A
48
- also known as real numbers
- contain up to 4 bytes of memory (32 bits)
- limited to how precise we can be
Doubles have DOUBLE the amount of PRECISION:
floating point is 4 bytes (32 bits) and doubles are 8 bytes (64 bits)
- is a type (not a data type)
- means that functions with void return type don't return a value
- parameter list of a function can be void meaning it doesnt take any parameters
- essentially a placeholder for "nothing"
code filename.c
make filename
filename./
no, booleans are not one of the 5 main data types however by using a library with this data type, booleans can be used
integer char, float, doubles, and void
a long series of characters. To use string data types, include the cs50.h header file
a long series of characters. To use string data types, include the cs50.h header file
alloes you to create your own data types
a structure : allow you to group an integer and string into one unit (and other types)
a data type and variable name
yes using a common to assign the same data type for several variables is valid
declaration
assignment
initialization
True
logical operators - logical AND (&&), logical OR (||) operators
relational operators - tests for equality or inequality, (x > y), (x != y), (x == y)
x !x
true false
false true
logical NOT (!) inverts the value if the operand
switch(x) {
case 1:
expression;
break;
case 2:
expression;
break;
default:
expression;
}
conditional statement that allows for enumeration of discrete cases instead of using boolean expressions
important to break between each case to not "fall through" each case unless desired
int x = (expression) ? 5 : 6;
^ checks expression. if true, assign 5 to variable x and if false assign value 6
in other words, it means...
int x;
if (expression)
{
x = 5;
}
else
{
x = 6;
}
for (start; expression; increment) {
}
example:
for (int i=0; i<10; i++)
{
}
Many modern Linux distributions have graphical user interfaces (GUI) allow easy mouse-based navigation
works with apple and Linux (differs from command prompt in microsoft PCs)
Typing "ls" in the command window lists the files in your workspace
Typing this would navigate you to your pset1 folder by using the cd (change directory) command. Typing ls after this, you would see other names if lists in your newly changed directory
clears terminal window
type "pwd" (present working directory)
you will return to your home window tilda
mkdir <directory>
(will make a new subdirectory located in the current directory)
cp <source> <destination>
duplicates the file you specify as <source> which it will save in <destination>
to copy DIRECTORIES, its similar:
cp -r <source> <destination>
where "r" stabds for recursive (tells cp to dive down into the directory and copy everything inside it)
rm <filename>
*note: there is NO recycle bin so confirm your removal kf the file using "y" and "n" keyboard inputs
to avoid *, can force the removal:
rm -f <filename>
to delete a directory:
rm -r <directory>
mv <source> <destination>
allows user to move the file from the location of <source> to the <destination>
chmod
rmdir
sudo
ln
man
clear
touch
diff
telnet
make ./hello
True
the declaration of a self-defined function in the firnat:
void <filename>(parameter)
... main() ...
1. preprocessing: converts #include lines to the underlying prototypes in the file
2. compiling: converts C to assembly language
3. assembly: converts assembly code to the binary code with 0's and 1's for the computer to understand
4. linking: combines compiled binary code from your own file, any #included .h files and stdio.h and links these blocks if code together into one final file of the file name of choice
debug50 ./buggy
*note: you can click the red circle next to a line (indicates the breakpoint). The debug checker does not run the code on the breakpoint line.
*note: icons at the top of the file allow you to step over or jump into the breakpoint
printf
debug50
rubber duck (talking to an inanimate object about the steps in your code)
cs50.ai
TYPE BYTES
bool 1
int 4
long 8
float 4
double 8
char 1
string ?
the "break" character /0 (in contrast to just 0 which may be confused
True
\0
a nul represents the termination, or end, of a string by a 0 bit value
initializes an array called sequence with five elements ([5] is NOT a position identifier)
argc tells you how many inputs follow the initialization statement ./filename in the command window and argv[ ] actually stores those inputs, for example:
./code 1 2 3 -->
code[0] is ./code
code[1] = 1
code[2] = 2
code[3] = 3
arrays are passed by reference, in other words they are not copied like with other variables but rather the actual array is used (hoping it does not gain an unwanted change). Other variables in C are passedby value in function calls.
- Name is a convention
- argc means argument count
- This integer-type argument will store the NUMBER of command-line arguments the user typed when the program was executed
- name is a convention
- argument vector
- an array of strings the user typed at the command-line when the program was executed
- each element of array is separated by a space when typed
- First element argv[0] is the file name
- last element of argv can be found at element argv[argc-1]
O() is a function that represents the minimum number of steps in a linear search
Ω() is a function that represents the maximum number of steps in a search
Θ() is a function that represents the number of steps when O and Ω are equal (Θ is uppercase theta)