Lecture 1: C Flashcards
programming quality standards are?
- correctness, or whether our code solves our problem correctly
- design, or how well-written our code is, based on how efficient and readable it is
- style, or how well-formatted our code is visually
What is compiler?
- Acompiler is a program that can convert one language to another, such as source code to machine code:
<img></img>
In C,mainachieves a similar effect as the Scratch block which is
when green flag clicked
there are a number of commands (Tirminal window) we might use llike:
- cd, for changing our current directory (folder)
- cp, for copying files and directories
- ls, for listing files in a directory
- mkdir, for making a directory
- mv, for moving (renaming) files and directories
- rm, for removing (deleting) files
- rmdir, for removing (deleting) directories
bool is a type of data which represents
a Boolean expression of eithertrueorfalse
Char is a type of data which represents
a single character likeaor2
Double is a type of data which represents
a floating-point value with more digits than afloat
float is a type of data which represents
a floating-point value, or real number with a decimal value
int is a type of data which represents
integers up to a certain size, or number of bits
long is a type of data which represents
integers with more bits, so they can count higher than anint
String is a type of data that represents
array of characters
Forprintf, too, there are different placeholders for each type of data, called:
format codes:
- %cfor chars
- %ffor floats or doubles
- %ifor ints
- %lifor long integers
- %sfor strings
//
comments
how many bits are include in int?
int uses 32 bits, which can only contain about four billion different values (2m psitive numbers & 2m negative numbers)
How many equals sings should used to compare two values in C?
== (2)
While Loops in C looks like?
while (true)
{
printf(“meow\n”);
}
Awhileloop repeats over and over as long as the expression inside is true, and sincetruewill always be true, this loop will repeat forever.
For loops and the difference between the two types (while, for)
the variable created within a for loop will only be accessible within the loop. In contrast, the variablewe created outside the while loop will still be accessible after the while loop finishes.
\n
new line
When will the date change?
In 2038, we’ll run out of bits to track time, since many years ago some humans decided to use 32 bits as the standard number of bits to count the number of seconds since January 1st, 1970. But since a 32-bit integer can only count up to about 2billion, in 2038 we’ll also reach that limit.