CS 145 final

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

An algorithm is a step by step sequence of instructions T or F

True

Documentation is so important that it spans almost the entirety of the software development cycle T or F

True

The maintenance phase of software development is usually the longest T or F

True

An algorithm can be expressed using flowchart, pseudocode, and formula but not

UML

cout << setw(3) << 1<< setfill('0') << setw(3) << 2; is

_ _1002

The analogy used to describe the idea that "what" a function does is important, but "how" it does it is not, is that of

a black box

select the statement that displays the contents of an array of 4 elements

for (int i=0; i<=3; i++) { cout << ar[i]; }

A function prototype is also known as the

function declaration

what is the function call that raises 10 to the power of 3

pow(10,3);

Select the one option that is not a part of a user-defined function usage.

signature

select the valid prototype for the function that displays the array from (1).

void display(int ar[], int len);

Select the correct prototype for the function getCartCoords.

void getCartCoords(string prompt, double& x, double& y);

Select the valid prototype for the function getNumber.

void getNumber(string prompt, int& num);

Write the definition for the function message(). It outputs the message "hi".

void message() { cout << "hi" endl; }

Give the prototype for the void function message(). It does not take any parameters.

void message();

Select the correct prototype for the function toCartCoords.

void toCartCoords(double r, double t, double& x, double& y);

Select the valid statement that adds 1 to the variable x

x +=1

What is the output after the following code executes? int i = 1; do { cout << *; i++; } while (i < 5);

****

if res is 10, then res -= 10+2 ; results in res having the value

-2

Select the valid comment

// hi

2/4 is

0

The correct result of the division 2 / 4 * 4 is

0

2/4.0 is

0.5

cout << setfill('0') << setw(3) << 1 << setw(3) << 2;

001002

setfill ('0') << setw(3) << 1 << setw(3) << 2;

001002

the correct remainder of 4 % 3 is

1

What is the output after the following code executes int i = 1; while (i <= 10) { cout << i << " "; i += 2;

1 3 5 7 9

What is the output after the following code executes? for (int i = 1; i <= 10; i += 2) { cout << i << " ";

1 3 5 7 9

What is the output after the following code executes? for (int i = 1; i <= 4; i++) { cout << i * i << " ";

1 4 9 16

4 steps of development and design

1) Analysis 10% 2) Design 20% 3) Coding 20% 4) Testing 50%

What is the value assigned to variable x after the following code is executed? int x = 0; if (x < 0) { x = -1; } else if (x >=0) { x = 6; } else if (x >= 5) { x = 3; }

6

What is the value assigned to variable x after the following code is executed? int x = 1; if (x < 0) { x = -1; } else if (x >=1) { x = 6; } else if (x >= 5) { x = 3; }

6

int changeIt(int val) { return val * 2; } what value does the function return if val is passed the value 3?

6

int changeIt(int val) { return val * 2; } The call changeIt(changeIt(2)) returns the value

8

The insert operator is represented by a

<<

Select the proper set up of any program that makes use of IO.

#include <iostream> using namespace std;

What is the output after the following code executes? for (int i = 10; i >= 1; i -= 2) { cout << i << " ";

10 8 6 4 2

10^2 *10^3

10^5

What is the output after the following code executes? void m() { cout << "1"; } m(); m(); m();

111

What is the output after the following code executes? for (int i = 1; i <= 2; i++) { for (int j = 1; j <= 2; j++) { cout << j; } cout << ".";

12.12

what is the output of the following code? int ar[] = {1,2,3}; for (int i=0; i<=2; i++) { cout << ar[i]; }

123

choose the decimal equivalent to the number 1.625e3, expressed in exponential notation

1625.

What is the value in x after the following statement evaluates? int x = 5 * 3.0 + 2; double

17 17.0

What is the value assigned to variable x after the following code is executed? int x = 0; if (x < 0) { x = -1; } if (x >=0) { x = 2; } if (x >= 5) { x = 3; }

2

What is the value assigned to variable x after the following code is executed? int x = 1; if (x < 0) { x = -1; } if (x >=1) { x = 2; } if (x >= 5) { x = 3; }

2

What is the value assigned to variable x after the following code is executed? int x = 6; if (x < 0) { x = -1; } if (x >=0) { x = 2; } if (x >= 5) { x = 3; }

2

What is the output after the following code executes? int i = 1; while (i <= 10 && i % 2 == 0) { cout << i << " "; i++; }

2 4 6 8 10

What is the final value in variable x after the following statement is evaluated? double x = sqrt( sqrt(16.0) );

2.0

The correct remainder of 3 % 4 is

3

What is the output after the following code executes? int val = 1; val = (val == 2)? 0 : 3;

3

What is the value assigned to variable x after the following code is executed? int x = 0; if (x < 0) { x = -1; } if (x >=0) { x = 6; } if (x >= 5) { x = 3; }

3

What is the value assigned to variable x after the following code is executed? int x = 1; switch (x) { case 1: x = 2; case 2: x = 3; break; case 3: x = 4; break; default: x = 5; break;

3

What is the value assigned to variable x after the following code is executed? int x = 2; switch (x) { case 1: x = 2; break; case 2: x = 3; break; case 3: x = 4; break; default: x = 5; break;

3

What is the output after the following code executes int i = 1; while (i <= 10) { i += 2; cout << i << " ";

3 5 7 9 11

the value in x after the expression double x= (int) 4.5; is evaluated is and expression int is

4.0 4

What is the value assigned to variable x after the following code is executed? int x = 4; switch (x) { case 1: x = 2; break; case 2: x = 3; break; case 3: x = 4; break; default: x = 5; break;

5

the expression 4/2+3 is

5

Select the invalid statement regarding the two passing modes.

Changing the parameter changes the argument with pass by value.

The most important piece of software on any computer is the

OS (operating system)

Select the valid statement regarding variable declarations

Their type defines the amount of memory allocated.

an array of 42 elements will arrange from an index of

[0] to [41]

select an assignment that correctly assigns a value to the 3rd element

arr[2] =1;

Which of the following would be considered a low level language.

assembly

Which of the following would be considered a machine level language.

binary

Select the most appropriate data type to be used to store whether it is raining or not.

bool

select the statement that reads a value from the keyboard into the first element of the array

cin >> ar[0];

Select the statement that will correctly read a user's full name

cin >> first >> last;

Select the statement that correctly reads in two integer values.

cin >> n1 >> n2;

Select the statement that would not appear in the function getCartCoords.

cin >> radius >> theta;

Select the valid declaration of the const PI.

const double PI = 3.1416;

what is the object to use for output to the screen

cout

Select the statement that correctly outputs a user's name.

cout << "Mary(space) " << "Poppins";

Select the valid body of the function getNumber.

cout << prompt; cin >> num;

Select the statement that will right align each value.

cout << setw(3) << 1 << endl << setw(3) << 22;

Select the statement that will tab 5 spaces from the left edge of the display

cout << setw(5) << " ";

what code will produce the output 1.23

cout<< setiosflags(ios::fixed) << setprecision(2) << 1.23456;

select the proper function call to display function from (2).

display(ar, 3);

Select the valid statement regarding the function main().

entry point of program

what is the most appropriate data type to be use to store the number of rainy days in a year

int

Select the valid definition of the function add

int add(int a, int b) { return a + b; }

Select the valid prototype for the function add.

int add(int a, int b);

int changeIt(int val) { return val * 2; } select the valid function call

int ans = changeIt(3);

select the valid array declaration

int arr[3];

select the invalid array declaration

int arr[];

Select the valid definition for the function main().

int main() { return 0; }

Select the proper call to the function add

int r = add(5, 6);

is 3=x valid or invalid

invalid

The hardest type of errors to resolve is __ errors.

logical

give the function call

message()

In order to use a function, you need to know several things. like:

the name of the function the library the function is defined in what the function does (parameters, return value) -you don't need to know how it is implemented


Ensembles d'études connexes

Equations of Parallel and Perpendicular Lines: Quiz

View Set

WordSmart for New GRE (Main words)

View Set

Psychology 321 exam 2 prep chapter 10

View Set

LCCW Adjunctive Care 3 - Cumulative Final (with practice questions)

View Set

Rome: Republic to Empire Lesson Quiz 11-3

View Set