P&A - Functions in C Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Functional decomposition

A

Functions break a larger program into smaller parts

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

How would you define a function?

A
return type function_name(parameter declarations)
{
variable declarations
Statements
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Entry point

A

Where the program starts running

In C, it’s the main() function

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

Function parameters

A

Allow us to pass a value from one function to another

e.g. numSwap(int num1, int num2)

Function parameters are automatic variables and are initialised with a copy of the value passed (pass by value)

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

Pass by value

A

Function parameters are automatic variables and are initialised with a copy of the value passed (pass by value)

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

What is the lifetime and scope of a function’s variables?

A

As the variables in a function are automatic, the scope is local to the function, and have a lifetime of only when the function is running

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

How many values can a function return at once?

A

One (single value)

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

void keyword

A

Used to declare that there is no return value, or can also use to declare no parameters

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

printf() function library?

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

what are the conversion characters to print the following:

strings
unsigned decimal
float
double
int
A
string - %s
unsigned decimal - %u
float - %f
double - %lf 
int - %d
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

escape characters

A
\n - new line
\t - tab 
\b - backspace 
\" - double quote
\\ - backslash
How well did you know this?
1
Not at all
2
3
4
5
Perfectly