ecs 32c

studied byStudied by 1 person
0.0(0)
Get a hint
Hint

break linenumber

1 / 106

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

107 Terms

1

break linenumber

create breakpoint at specified line

New cards
2

break file:linenumber

create breakpoint at line in file

New cards
3
what does #include <stdio.h> do?

reads the content of the header file

New cards
4

when do you declare variables?

before use

New cards
5

uninitialized variable assumes a…

default value

New cards
6

before we leave the os, you must always

free the memory from the heap

New cards
7

stack

special type of list where the last element in (push) is the first out (pop)

New cards
8

in a stack, you read and write from

the same end of the list

New cards
9

what does the following block of code do?

void push(int elem) { stack_buffer[itop++] = elem; }

adds element to top of stack

New cards
10

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

New cards
11

in a stack, if itop == 0, that means…

the stack is empty

New cards
12

when must functions be declared?

before use

New cards
13

arguments

local variables, values passed from caller

New cards
14

return value

single value returned to caller when function exits

New cards
15

void

signifies no return value/arguments

New cards
16

strings are stores as

character array

New cards
17

what does it mean for a string to be null-terminated?

last character in array is ‘\0’ null (not explicitly in string literals)

New cards
18

what does #define msg “hello” do?

defines msg as “hello” throughout source fikle

New cards
19

datatype of an onject in memory determines…

the set of values it can have and what operations that can be performed on it

New cards
20

operators specify

how an object can be manipulated

New cards
21

expressions

a combination of values, variables, operators, and functions

New cards
22

variables

a named link/reference to a value stored in the system’s memory or an expression that can be evaluated

New cards
23

how does the unsigned version differ from its signed counterparts?

the unsigned version is roughly double the range of its signed counterparts

New cards
24

what is this operator? “==”

relational operator meaning “equal to”

New cards
25

what is this operator? “!=”

relational operator meaning “not equal to”

New cards
26

what is this operator? “&&”

logical operator for “and”

New cards
27

what is this operator? “||”

logical operator for “or”

New cards
28

logical operator for “!”

logical operator for “not”

New cards
29

the for loop has three expressions:

  1. initialization

  2. condition

  3. increment

New cards
30

if any of the three expressions in a for loop are left empty,

the condition is assumed to be “true”

New cards
31

do-while loop

differs from the while loop - condition evaluated after each iteration. form:

do {

////

} while (condition);

New cards
32

what is the “break” keyword?

exits innermost loop or switch statement to exit early

New cards
33

variable scope

the region in which a variable is valid

New cards
34

variables declared outside of a function have (_) scope

global

New cards
35

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

New cards
36

goto

allows you to jump conditionally to arbitrary part of your code

New cards
37

putchar(c)

puts the character c on the standard output and returns the character printed or EOF on error

New cards
38

int getchar()

returns the next character from standard input and returns EOF on error

New cards
39

what does this do? a.out < file.txt

known as input redirection. treats file.txt as source of standard input.

New cards
40

in printf format specification, what is d and i?

integer

New cards
41

in printf format specification, what is x and X?

integer (hex)

New cards
42

in printf format specification, what is u?

unsigned integer

New cards
43

in printf format specification, what is c?

character

New cards
44

in printf format specification, what is s?

string

New cards
45

in printf format specification, what is f?

float

New cards
46

in printf format specification, what is d?

double

New cards
47

in printf format specification, what is e and E?

float(exp)

New cards
48

in printf format specification, what is %?

literal %

New cards
49

the end of the string is specified using

0

New cards
50

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.

New cards
51

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.

New cards
52

we can read data from text/binary files using

fopen()

New cards
53

fopen returns a () to the file stream if it exists or () otherwise

pointer; NULL

New cards
54

int fclose(FILE*fp)

closes the stream. automatically called on all open files when program terminates

New cards
55

int getc(FILE*fp)

reads a single character from the stream and returns the character read or EOF on error/end of file

New cards
56

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

New cards
57

int putc(int c, FILE*fp)

writes a single character c to the output stream, and returns the character written or EOF on error

New cards
58

int fputs(char line[], FILE*fp)

writes a single line to the output stream, and returns 0 on success, EOF otherwise

New cards
59

int fscanf(FILE*fp, char format[], arg1, arg2)

similar to scanf, sscanf, and reads items from intput stream fp

New cards
60

int main(int argc, char*argv[])

argc is the count of arguments, and argv is the array of pointers to each of the arguments

New cards
61

pointer

memory address of a variable

New cards
62

address can be used to…

access/modify a variable from anywhere

New cards
63

strings are stored as…

null-terminated character arrays, where the last character == ‘\0’

New cards
64

what are the string copy functions?

strcpy(), strncpy()

New cards
65

what are the string comparison functions?

strcmp(), strncmp()

New cards
66

what is the string length functions?

strlen()

New cards
67

what are the string concatenation functions?

strcat(), strncat()

New cards
68

what are the string search functions?

strchr(), strrchr()

New cards
69

The average and worst case big-O for quicksort are

  • average: O(nlogn)

  • worst case: O(n^2)

New cards
70

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)

New cards
71

average big-O for binary search

O(logn)

New cards
72

worst case Big-O for binary search:

logarithmic time

New cards
73

structure

a collection of related variables (of possible different types) grouped together under a single name

New cards
74

struct defines…

a new datatype

New cards
75

members of a struct

the variables declared within a structure

New cards
76

‘→’ operator

used to access members from structure pointers

New cards
77

how to declare arrays of int:

int x[10];

New cards
78

declaring arrays of structure

struct point p[10]

New cards
79

initializing arrays of int

int x[4] = {0, 20, 10, 2};

New cards
80

initializing arrays of structure

struct point p[3] = {0, 1, 10, 20, 30, 12};

struct point p[3] = {{0, 1}, {10, 20}, {30, 12}};

New cards
81

the size of a structure is…

greater than or equal to the sum of the sizes of its members

New cards
82

union

is a variable that may hold objects of different types/sizes in the same memory location

New cards
83

the size of the union variable is equal to

the size of its largest element

New cards
84

bit-field

a set of adjacent bits within a single ‘word’

New cards
85

malloc(size_t n)

allocates blocks of memory, and returns a pointer to unitialized block on success. returns NULL on failure

New cards
86

calloc(size_t size_n size)

allocates an array of n elements each of which is ‘size’ bytes. initializes memory to 0

New cards
87

free()

frees memory allocated to my malloc()

New cards
88

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

New cards
89

binary tree

a dynamic data structure where each node has at most two children.

New cards
90

a binary search tree

a binary tree with ordering among its children

New cards
91

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”

New cards
92

pointer array

array of pointers

New cards
93

what is: int *arr[20];?

an array of pointers to int’s

New cards
94

what is: char *arr[20];?

an array of pointers to char’s

New cards
95

what is: char *strs[10];?

an array of char arrays (or strings)

New cards
96

stack

a special type of list, where the last element in (push) is first out (pop)

New cards
97

in a stack, where do you read and write from the list?

the same end

New cards
98

store the stack as an…

a array buffer

New cards
99

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.

New cards
100

True or False: A long double can be used if range of a double is not enough to accommodate a real number.

True.

New cards

Explore top notes

note Note
studied byStudied by 55 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 10 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 55 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 23 people
Updated ... ago
4.5 Stars(2)
note Note
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 12 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 31730 people
Updated ... ago
4.8 Stars(234)

Explore top flashcards

flashcards Flashcard45 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard36 terms
studied byStudied by 30 people
Updated ... ago
5.0 Stars(4)
flashcards Flashcard275 terms
studied byStudied by 21 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard36 terms
studied byStudied by 48 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard171 terms
studied byStudied by 3 people
Updated ... ago
4.0 Stars(1)
flashcards Flashcard88 terms
studied byStudied by 38 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard25 terms
studied byStudied by 24 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard464 terms
studied byStudied by 34601 people
Updated ... ago
4.1 Stars(395)