Looks like no one added any tags here yet for you.
break linenumber
create breakpoint at specified line
break file:linenumber
create breakpoint at line in file
reads the content of the header file
when do you declare variables?
before use
uninitialized variable assumes a…
default value
before we leave the os, you must always
free the memory from the heap
stack
special type of list where the last element in (push) is the first out (pop)
in a stack, you read and write from
the same end of the list
what does the following block of code do?
void push(int elem) { stack_buffer[itop++] = elem; }
adds element to top of stack
what does the following block of code do?
int pop(void) { if (itop > 0)
return stack_buffer[--itop];
el
return 0; }
remove element from top of stack
in a stack, if itop == 0, that means…
the stack is empty
when must functions be declared?
before use
arguments
local variables, values passed from caller
return value
single value returned to caller when function exits
void
signifies no return value/arguments
strings are stores as
character array
what does it mean for a string to be null-terminated?
last character in array is ‘\0’ null (not explicitly in string literals)
what does #define msg “hello” do?
defines msg as “hello” throughout source fikle
datatype of an onject in memory determines…
the set of values it can have and what operations that can be performed on it
operators specify
how an object can be manipulated
expressions
a combination of values, variables, operators, and functions
variables
a named link/reference to a value stored in the system’s memory or an expression that can be evaluated
how does the unsigned version differ from its signed counterparts?
the unsigned version is roughly double the range of its signed counterparts
what is this operator? “==”
relational operator meaning “equal to”
what is this operator? “!=”
relational operator meaning “not equal to”
what is this operator? “&&”
logical operator for “and”
what is this operator? “||”
logical operator for “or”
logical operator for “!”
logical operator for “not”
the for loop has three expressions:
initialization
condition
increment
if any of the three expressions in a for loop are left empty,
the condition is assumed to be “true”
do-while loop
differs from the while loop - condition evaluated after each iteration. form:
do {
////
} while (condition);
what is the “break” keyword?
exits innermost loop or switch statement to exit early
variable scope
the region in which a variable is valid
variables declared outside of a function have (_) scope
global
what is the difference between the “while” loop, “do… while” loop, and “for” loop?
while loop tests condition before execution of the block
do… while loop tests condition after execution of the block
for loop provides intialization, testing, and iteration together
goto
allows you to jump conditionally to arbitrary part of your code
putchar(c)
puts the character c on the standard output and returns the character printed or EOF on error
int getchar()
returns the next character from standard input and returns EOF on error
what does this do? a.out < file.txt
known as input redirection. treats file.txt as source of standard input.
in printf format specification, what is d and i?
integer
in printf format specification, what is x and X?
integer (hex)
in printf format specification, what is u?
unsigned integer
in printf format specification, what is c?
character
in printf format specification, what is s?
string
in printf format specification, what is f?
float
in printf format specification, what is d?
double
in printf format specification, what is e and E?
float(exp)
in printf format specification, what is %?
literal %
the end of the string is specified using
0
int sprintf(char string [], char format[], arg1, arg2)
format specification is the same as printf, and the output is written to string. returns the number of character written or negative value on error.
int sscanf(char str[], char format[], arg1, arg2)
the format specification is the same as scanf, and the input is read from str variable. returns the number of items read or negative value on error.
we can read data from text/binary files using
fopen()
fopen returns a () to the file stream if it exists or () otherwise
pointer; NULL
int fclose(FILE*fp)
closes the stream. automatically called on all open files when program terminates
int getc(FILE*fp)
reads a single character from the stream and returns the character read or EOF on error/end of file
char[] fgets(char line[], int maxlen, FILE*fp)
reads a single line (upto maxlen characters) from the input stream (including linebreak). returns a pointer to the character array that stores the line (read-only). return NULL if end of stream
int putc(int c, FILE*fp)
writes a single character c to the output stream, and returns the character written or EOF on error
int fputs(char line[], FILE*fp)
writes a single line to the output stream, and returns 0 on success, EOF otherwise
int fscanf(FILE*fp, char format[], arg1, arg2)
similar to scanf, sscanf, and reads items from intput stream fp
int main(int argc, char*argv[])
argc is the count of arguments, and argv is the array of pointers to each of the arguments
pointer
memory address of a variable
address can be used to…
access/modify a variable from anywhere
strings are stored as…
null-terminated character arrays, where the last character == ‘\0’
what are the string copy functions?
strcpy(), strncpy()
what are the string comparison functions?
strcmp(), strncmp()
what is the string length functions?
strlen()
what are the string concatenation functions?
strcat(), strncat()
what are the string search functions?
strchr(), strrchr()
The average and worst case big-O for quicksort are
average: O(nlogn)
worst case: O(n^2)
how to do quicksort?
choose a pivot element
move all the elements less than pivot to one side, all elements greater than pivot to other
sorts sides individually (recursive algorithm)
average big-O for binary search
O(logn)
worst case Big-O for binary search:
logarithmic time
structure
a collection of related variables (of possible different types) grouped together under a single name
struct defines…
a new datatype
members of a struct
the variables declared within a structure
‘→’ operator
used to access members from structure pointers
how to declare arrays of int:
int x[10];
declaring arrays of structure
struct point p[10]
initializing arrays of int
int x[4] = {0, 20, 10, 2};
initializing arrays of structure
struct point p[3] = {0, 1, 10, 20, 30, 12};
struct point p[3] = {{0, 1}, {10, 20}, {30, 12}};
the size of a structure is…
greater than or equal to the sum of the sizes of its members
union
is a variable that may hold objects of different types/sizes in the same memory location
the size of the union variable is equal to
the size of its largest element
bit-field
a set of adjacent bits within a single ‘word’
malloc(size_t n)
allocates blocks of memory, and returns a pointer to unitialized block on success. returns NULL on failure
calloc(size_t size_n size)
allocates an array of n elements each of which is ‘size’ bytes. initializes memory to 0
free()
frees memory allocated to my malloc()
linked list
a dynamic data structure that consists of a sequence of records where each element contains a link to the next record in the sequence
can be singly linked, doubly linked, or circular
binary tree
a dynamic data structure where each node has at most two children.
a binary search tree
a binary tree with ordering among its children
in a binary tree, usually, all elements in the left subtree are assumed to be (“less”/”more”) than the root element and all elements in the right subtree are assumed to be (“lesser”/”greater”) than the root element
“less”; ”greater”
pointer array
array of pointers
what is: int *arr[20];?
an array of pointers to int’s
what is: char *arr[20];?
an array of pointers to char’s
what is: char *strs[10];?
an array of char arrays (or strings)
stack
a special type of list, where the last element in (push) is first out (pop)
in a stack, where do you read and write from the list?
the same end
store the stack as an…
a array buffer
True or False: Size of short integer and long integer would vary from one platform to another.
True. Depending on the os/compiler/system architechture you are working on, the range of data types can vary.
True or False: A long double can be used if range of a double is not enough to accommodate a real number.
True.