Midterm II Flashcards

0
Q

What are the advantages of the waterfall method

A

Natural flow
Widely used
Reinforces planning first
Clear milestones

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

What are the steps in the waterfall method

A

Gathering resources-design-implementation-testing-maintenance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the disadvantages of the waterfall method

A

Not practical
Difficult to implement change
Designers may not be aware of implementation difficulties

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the steps of the rapid prototyping method

A

Gathering preliminary requirements
Fast prototyping
User evaluation of the prototype
Repeat

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Advantages of rapid prototyping method

A

Ensures that product meets clients needs

Easy to implement change

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Disadvantages of the rapid prototyping method

A

May not be able to have adequate user involvement

Cost of prototype development

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why test software?

A
Produce robust software
Maintain reputation
Lower cost (easier to fix bugs before release)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What do we test during the testing phase

A

Whether a program works
Input
Output
Set of conditions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do we test?

A

Ask how can we make the program fail
Regular tests
Boundary tests
Error testing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is white box testing

A

Use internal knowledge of implementation to guide the selection of test cases
This will achieve maximum code coverage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is black box testing

A

Use specification to guide the selection of test cases

To achieve the maximum coverage of cases give in the specs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is debugging

A

A methodical process of finding and reducing bugs or defects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the steps of debugging

A
Identify where things go wrong
Track program state
Current location in program
Current value of variables
Number of iterations through the loop
Find when expected state does not match actual state
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is printf debugging

A

Use a print statement to print values of variables and program location

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Print debugging strategies

A

Linear -start at the beginning and add printf until the end is reached
Binary -start in middle of program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Disadvantages of printf debugging

A

Time consuming

Modify recompile rerun

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is gdb

A

A source level debugger.

Maps the state to source code and alls to view variable values and set breakpoints

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a breakpoint

A

Internal pausing place in the program

Allows programmers to print variable values and resume running till next break point

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Max value of an int

A

2^16

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Max value of an unsigned int

A

2^16-1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Float vs double

A

Float keeps 6 significant digits and double keeps 15

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Char storage space

A

8 bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

getchar()

A

Reads a character and assigns it to a variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

putchar()

A

Prints the character in the brackets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is an implicit conversion

A

Implicit conversions are type conversions handled by compilers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What are the two cases where implicit conversions take place

A

When operands in a math operation don’t have the same type they will convert to the more complex type
Int will convert to float will convert to double

Secondly when the type expressed doesn’t match the value assigned
Ex: int=8.34 becomes 8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

How to tell compiler to convert types and what is this called

A

(type) expression

This is called explicit conversion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

typedef

A

Typedef is a keyword to assign alternative names to existing types
typedef typename alternative_name

28
Q

sizeof()

A

The sizeof operator is used like this :
sizeof(type)

To find the number of bytes (not bits) required to store that type

29
Q

What is a scalar type

A

A scalar type is composed of a single element

30
Q

What is an aggregate type

A

An aggregate type is composed of multiple elements like an array

31
Q

Declare a one dimensional array

A

type name[size]

32
Q

Where are arrays stored

A

In stack data rather than in heap data like Java. This means that arrays must have a defined size before run time and can not be dynamically allocated

33
Q

What happens when you try to access an out of bounds item in your array in C

A

C does not require that subscript bounds be checked so the behaviour will be undefined. This makes it harder to debug but ultimately more efficient

34
Q

Array initializer

A

When an array is initialized it is assignment values. If it is not initialized it is not assigned values (unlike in Java)

35
Q

How do you find the size of an array using the sizeof operator

A

int size = sizeof(array)/sizeof(array[0]);

36
Q

How do we access an item in a 2D array

A

int m[row][column];

37
Q

How is a 2D array stored in memory?

A

Elements of a 2D array are stored in row major order

38
Q

How to initialize a 2D array?

A

Can use a nested initializer or fill it using nested loops

39
Q

What is a variable length array?

A

A variable length array is an array whose length is declared as a variable. Ex: int a[len]

This is possible only if a value has been assigned to len before the array is declared. In addition a VLA can be multidimensional but can not have initializers

40
Q

What is a function

A

A sequence of statements grouped together and given a name

41
Q

Why use functions?

A

Divide program into manageable pieces

Avoid duplicating code

42
Q

How to declare a function

A

returntype name(inputtype varname)

43
Q

What happens when you want to find out what scanf returns? Or printf

A

Scanf returns the number of values successfully read from input
Printf returns te number of characters printed

44
Q

Argument vs parameters

A

An argument is what you actually pass to a function when you’re calling it. A parameter is what’s used in a function definition or declaration.

45
Q

Argument passed by value

A

You only pass a copy of the value that has been assigned to a variable so the original variable remains untouched. Except in the case of arrays

46
Q

What is a call stack

A

A call stack is a data structure in memory that stores information about active functions of a program

47
Q

What is a wrapper function

A

The function that calls the recursive function

48
Q

What part of memory is used to store external variables

A

The data part of memory

49
Q

Layout of single file c program

A
#include directives
#define directives
type definitions
global variable definitions
function prototypes (except main) 
main
other function definitions
50
Q

What is a pointer

A

A pointer is a variable that stores a memory address

51
Q

How to declare a pointer

A

type *pointername

52
Q

How to initialize pointer

A

int i, *p;

p=&i;

54
Q

What will happen if we perform pointer arithmetic on pointers that do not point to array elements?

A

This will result in an undefined behaviour

55
Q

what are local variables and where are they stored?

A

We know that local variables are variables defined inside the body of a function. When we learned the call stack,
we also learned that their storage is allocated automatically once the stack frame of the function is created, and
deallocated automatically when the stack frame is popped out of the call stack.Local variables also have block scope, which means that they are visible from their point of declaration to the end
of the enclosing function body.

56
Q

what is an external variable and where is it stored?

A

Indeed, in C, we can declare variables outside any functions, and these
variables are called external variables or global variablesExternal variables have static storage duration. This means that they have permanent memory storage locations
when the program is executing. Thus they retain their values throughout program execution. Previously we learned
that the memory of a process is composed of four parts. Among these four parts, the data part is used to store
external variables., External variables have file scope. This means that they are visible from the point of declaration to the end of
the enclosing file. In other words, after we declare an external variable somewhere in the program, any function
defined afterwards can access this variable. Actually, we will see later that the external (i.e., global) variables have
global scope; i.e., they are accessible from other files as well. If a global variable is defined with the keyword
static then it is visible only within the file scope. It is still stored in the static memory; i.e., data part of the
memory. Actually, we do not call it global or external variable in this case, but just static variable

57
Q

how should we layout our C program

A
#include directives
#define directives
type definitions
global variable definitions
function prototypes (except main)
main
other function definitions
58
Q

what happens when we add an integer to a pointer

A

First, we can add an integer to a pointer. If pointer p points to a[i], then p+j points to a[i+j]. In other words,
p+j points to an element that is j positions forward in the same array.

59
Q

how do we write a string

A

A C string is a sequence of characters followed by a null character (’\0’). Thus, a null character is used to mark
the end of the string. A null character is a character whose numeric, i.e., ASCII, value is 0. This is why it can be
written using the escape sequence ‘\0’When using strings we frequently need to have in mind the byte required to store the null character at the end.
Thus to store a string literal of n characters, we need n + 1 bytes

60
Q

how to declare a string using a pointer

A

char *p = “hello, world\n”;

61
Q

how to declare a string using an array

A

char str1[6] = “abc”;

62
Q

what does char* strcpy(char *s1, const char *s2);

do?

A

it copies s1 to s2 and returns s2. does not change the s1 object

63
Q

what does char* strcat(char *s1, const char *s2);

do?

A

adds s2 to s1 and returns s1

64
Q

what does int strcmp(const char *s1, const char *s2);

do?

A

strcmp compares the strings lexicographically

65
Q

what does size_t strlen(const char *s1); do?

A

returns the length of the string

66
Q

what is a header file?

A
– Files that allow different source files (*.c) to share
– Function prototypes
– Type definitions
– Macro definitions
– etc.
– Naming convention: *.h
67
Q

how to include your header files?

A

include “file_name”

– First search the current directory, if not found then
– directories in which system header files reside

68
Q

how do we use preprocessor conditional compilation

A
– Example (bit.h):
#ifndef BIT_H
#define BIT_H
typedef int Bit;
#endif
– Meaning:
– If BIT_H is not defined:
– Define BIT_H
– Include other code up to:
– #endif