Midterm II Flashcards

(68 cards)

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
What is an implicit conversion
Implicit conversions are type conversions handled by compilers
25
What are the two cases where implicit conversions take place
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
26
How to tell compiler to convert types and what is this called
(type) expression | This is called explicit conversion
27
typedef
Typedef is a keyword to assign alternative names to existing types typedef typename alternative_name
28
sizeof()
The sizeof operator is used like this : sizeof(type) To find the number of bytes (not bits) required to store that type
29
What is a scalar type
A scalar type is composed of a single element
30
What is an aggregate type
An aggregate type is composed of multiple elements like an array
31
Declare a one dimensional array
type name[size]
32
Where are arrays stored
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
What happens when you try to access an out of bounds item in your array in C
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
Array initializer
When an array is initialized it is assignment values. If it is not initialized it is not assigned values (unlike in Java)
35
How do you find the size of an array using the sizeof operator
int size = sizeof(array)/sizeof(array[0]);
36
How do we access an item in a 2D array
int m[row][column];
37
How is a 2D array stored in memory?
Elements of a 2D array are stored in row major order
38
How to initialize a 2D array?
Can use a nested initializer or fill it using nested loops
39
What is a variable length array?
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
What is a function
A sequence of statements grouped together and given a name
41
Why use functions?
Divide program into manageable pieces | Avoid duplicating code
42
How to declare a function
returntype name(inputtype varname)
43
What happens when you want to find out what scanf returns? Or printf
Scanf returns the number of values successfully read from input Printf returns te number of characters printed
44
Argument vs parameters
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
Argument passed by value
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
What is a call stack
A call stack is a data structure in memory that stores information about active functions of a program
47
What is a wrapper function
The function that calls the recursive function
48
What part of memory is used to store external variables
The data part of memory
49
Layout of single file c program
``` #include directives #define directives type definitions global variable definitions function prototypes (except main) main other function definitions ```
50
What is a pointer
A pointer is a variable that stores a memory address
51
How to declare a pointer
type *pointername
52
How to initialize pointer
int i, *p; | p=&i;
54
What will happen if we perform pointer arithmetic on pointers that do not point to array elements?
This will result in an undefined behaviour
55
what are local variables and where are they stored?
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
what is an external variable and where is it stored?
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
how should we layout our C program
``` #include directives #define directives type definitions global variable definitions function prototypes (except main) main other function definitions ```
58
what happens when we add an integer to a pointer
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
how do we write a string
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
how to declare a string using a pointer
char *p = "hello, world\n";
61
how to declare a string using an array
char str1[6] = "abc";
62
what does char* strcpy(char *s1, const char *s2); | do?
it copies s1 to s2 and returns s2. does not change the s1 object
63
what does char* strcat(char *s1, const char *s2); | do?
adds s2 to s1 and returns s1
64
what does int strcmp(const char *s1, const char *s2); | do?
strcmp compares the strings lexicographically
65
what does size_t strlen(const char *s1); do?
returns the length of the string
66
what is a header file?
``` – Files that allow different source files (*.c) to share – Function prototypes – Type definitions – Macro definitions – etc. – Naming convention: *.h ```
67
how to include your header files?
#include "file_name" – First search the current directory, if not found then – directories in which system header files reside
68
how do we use preprocessor conditional compilation
``` – 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 ```