ADTs
Files
Pointers
Macros
Random Mops
100

What is the purpose of an ADT?

To hide implementation from the user.

100

What is the C standard library function used to open a file in read mode?

fopen() with mode = r

100

What is the syntax for declaring a pointer to an integer in C?

int * ptr

100

This keyword starts all macros.

What is #define?

100

What is the maximum value that can be stored in an unsigned char variable in C?

255

200

The ________ for an ADT serves as the interface for the client.

Header file

200

What are the 3 main modes of opening a file?

Read, Write, and Append

200

What are the 3 memory allocation functions used in the course?

Malloc, Calloc, Realloc

200

This preprocessor command removes a currently defined macro.

What is #undef?

200

What is the size of a float in C?

4 bytes

300

How should the struct for an ADT be made available in the header file?

Using a typedef

300

What must you always do before you're finished with a file?

Close

300

I couldn't think of more questions, so here's some free points!

Yay!

300

This allows you to concatenate variable names in a macro.

What is ##?

300

What is the syntax for a ternary operator in C?

(condition) ? true_expression : false_expression

400

This is a type that cannot be cast to a void pointer.

Float, double

400

What function reads a file as binary data?

fread
400

Define a function pointer called function with a single int parameter and which does not return anything.

void (*function)(int a);

400

This macro gets the current file name.

What is __FILE__?

400

Given the following defines:

What is the result of the following code?

#define ADD4(x)    4+x

#define SQU(y)     y*y

int main( void ){

    int a =  3;

    printf("%d\n", SQU(ADD4(a)));

    return 0;

}

19

500

Write a basic constructor for an ADT called "CoolADT"

The struct is called "struct coolADT_s" and the header file is the following:

typedef struct coolADT_s * CoolADT;

CoolADT cool_create();

CoolADT cool_create(){
    CoolADT newCool = (CoolADT) malloc(sizeof(struct coolADT_s));

    return newCool;

}

500

Complete the following line to open a file called "example.txt" to read and write to it as binary data:


FILE * file =

fopen("example.txt", "br+);

500

What would the following return:


int ** a;
int * b;
b = 5;
a = &b;
*a += 1;
printf("a: %d, b: %d \n", *a, b);

a: 9, b: 9

500

Write a macro that evaluates to true if the given letter is lowercase.

#define LOWERCASE(x) (x >= 'a' && x <= 'z')

500

What would the dependency tree of the following makefile look like?

CC=gcc

CC_FLAGS=-Wall -Wextra -pedantic -std=c99

main: main.o list.o person.o

    $(CC) $(CC_FLAGS) -o main main.o list.o person.o

main.o: main.c list.h person.h

    $(CC) $(CC_FLAGS) -c main.c

list.o: list.c list.h

    $(CC) $(CC_FLAGS) -c list.c

person.o: person.c person.h

    $(CC) $(CC_FLAGS) -c person.c


M
e
n
u