COP3223C Exam 2

Ace your homework & exams now with Quizwiz!

4 different storage classes

- auto - register - static - extern

Which of the following are true regarding arrays. Select all that apply. - sequential elements - various data type - non-sequential elements - fixed size - varying size - same data type

- sequential elements - fixed size - same data type

global

Outside of all functions.

(%)

Reminder after integer division

Auto (Storage Class)

The auto storage class is the default storage class for all local variables Ex; { int mount; auto int month; }

Extern (Storage Class)

The extern storage class is used to giver reference of a global variable that is visible to ALL the program files. - extern is used to declare global variable or function in another file

A program can have same name for local and global variables but the value of local variable inside a function will take preference. (T/F)

True

A program stops its execution when break statement is encountered. (T/F)

True

int a = 30; if( a < 20 ) { printf("a is less than 20\n" ); } else { printf("a is not less than 20\n" ); } Given the source code above, what would output to the command prompt or terminal window?

a is not less than 20

Regarding calling a function, arguments are used when _________ a function. - declaring - calling - returning a value - defining

- calling

int max(int num1, int num2); Given the function declaration above, which parts of the function comprise the function signature? Select all that apply. - parameter int num1 - Function name max - parameter int num2 - Return type int - ; (semi-colon)

- parameter int num 1 - Function name max - parameter int num 2

formal parameter

In the definition of function parameters.

local

Inside a function or a block.

____________ is the built in multiway decision statement in C? - switch - while - if - for

Switch

A function declaration

Tells the compiler about a function's name, return type, and parameters.

break

Terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch.

Register (Storage Class)

The register storage class is used to define variables that should be stored in a register instead of RAM. Ex; { register int miles; }

Function Return Type

The data type of the value the value the function returns.

Static (Storage Class)

The static storage class instructs the compilers to keep a local variable in existence during the life-time of program instead of creating and destroying it each time it comes into and goes out of scope - is used on a global variable, it causes only one copy of that member to be shared by all the objects of its class. Ex; void func(void); static int count = 5; // global variable Ex; void func( void ) { static int i = 5; // local static variable }

goto

Transfers control to the labeled statement.

A specific element in an array is accessed by an index. (T/F)

True

All arrays consist of contiguous memory locations. (T/F)

True

All arrays have 0 as the index of their first element which is also called the base index. (T/F)

True

C programming language assumes any (non-zero) and (non-null) values as true. (T/F)

True

C programming language assumes any (zero) or (null) values as false. (T/F)

True

The scandalous truth is that C has no arrays — that they are merely cleverly disguised pointers. (T/F)

True

To call a function you simply need to pass the required parameters along with the function name. (T/F)

True

(!)

Used to reverse the logical state of its operand

int a = 30; if( a == 10 ) { printf("Value of a is 10\n" ); } else if( a == 20 ) { printf("Value of a is 20\n" ); } else if( a == 30 ) { printf("Value of a is 30\n" ); } Given the source code above, what would output to the command prompt or terminal window?

Value of a is 30

What punctuation is used to declare the explicit size of an array upon declaration when the array is not initialized during declaration? - {} - = - () - []

[]

If an array is a three-dimensional array, how many sets of square brackets are used to identify each element of the array? - [][][][] - [][] - [] - [][][]

[][][]

int a =10; if( a < 20) { printf("a is less than 20\n"); } What would the output be for the if condition?

a is less than 20

Which of the following is the only methodology to return an array from a function in the C programming language? - int[10} myFunction() - None of these - int[]myFunction() - int*myFunction()

int*myFunction()

A function definition

provides the actual body of the function.

Storage

the scope and life-time of variables and/ or functions within a C program

Formal parameters as a pointer

void myFunction(int * param)

Formal parameters as a sized array

void myFunction(int param[10])

Formal parameter as an unsized array

void myFunction(int param[])

nested loop

One or more loops inside any other while, for, or do...while loop.

(||)

; if any of the two operands is non-zero, then the condition becomes

A function

A group of statements that together perform a task.

(+)

Adds two operands

Which of the following is branching statement of C language? - switch statement - if...else statement - All of these - if statement

All of these

for loop

Allows you to efficiently write a loop that needs to execute a specific number of times; a valid implementation may contain only two semi-colons.

(=)

Assigns values from right side operands to left side operand

(&)

Bitwise AND

continue

Cause the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

(>=)

Checks if left operand is greater than or equal to the right operand

(==)

Checks if two operands are equal

(!=)

Checks if two operands are not equal

(?:)

Conditional expression; if Condition is true ? then value X: otherwise value Y

Function Body

Contains a collection of statements that define what the function does.

When calling a function, call by value refers to what behavior? - copies the actual value of an argument into the formal parameter of the function - uses a pointer - copies the address of an argument into the formal parameter - None of these

Copies the actual value of an argument into the formal parameter of the function

(--)

Decrements integer by one

main()

Every C program has at least this one function.

do...while loop

Is guaranteed to execute at least one time.

(/=)

It divides the left operand with the right operand and assigns the result to the left operand

(-=)

It subtracts the right operand from the left operand and assigns the result to the left operand.

(*)

Multiples two operands

parameter list

Refers to the type, order, and number of the parameters of a function.

while loop

Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.

sizeof()

Returns the size of a variable


Related study sets

AP Psych: Unit 4: Sensation and Perception

View Set

Chapter 1: Modern Network Security Threats

View Set

Unit 4 Reading 2: MENA region intenet use

View Set

Legal Aspects of Real Estate Ch. 15; Licensing and Regulations

View Set