C Flashcards
1
Q
include
A
Library then add name
2
Q
int main (void) { }
A
beginning of program
3
Q
get_string()
A
- ask for a string
4
Q
printf()
A
print string
5
Q
printf(“hello,%s\n”, answer)
A
print variable
6
Q
%c
A
char placeholder
7
Q
%f
A
float, double placeholder
8
Q
%i
A
int placeholder
9
Q
%li
A
long placeholder
10
Q
%s
A
string placeholder
11
Q
\n
A
new line
12
Q
return-type name (argument_list)
A
- make a new function
- function is referred to on top, but body is below code
- first void is type of output
- second void is type of input
- when a function has no arguments it is void
int add_two_ints (int a, int b); \function declaration
int main (void) { int x = 8; int y = 9;
printf(“%i”, add_two_ints(x,y));
}
int add_two_ints (int a, int b) { return a + b; }
13
Q
int
A
- 4 bytes (32 bit)
~- 2 bill to ~+2 bill
14
Q
unsigned int
A
- no negatives
- 2x positive number ~+4 bill
15
Q
chars
A
- store single characters
- 1 byte (8 bits)
- 0 to 127
16
Q
float
A
- real numbers (decimal)
- 4 byte (32 bits)
- precision problem
17
Q
double
A
- real numbers (decimal)
- 8 byte (64 bits)
more precise
18
Q
void
A
- type, not datatype
- function with void does not return value
- parameter with void does not take parameter
- placeholder meaning ‘nothing’
19
Q
bool
A
- include library cs50
- boolean value
- true or false
20
Q
create variable [type] [name]
A
int number;
char letter;
int height, width;
21
Q
initializing
A
int number = 17;
char letter = “15”;