Programming midterm

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is the correct way to write the following condition : 60 <= pass_grade <= 100

((pass_grade >= 60) && (pass_grade <= 100))

What is the correct way to write the condition y < x < z?

((y < x) && (x < z))

Which of the following boolean expressions tests to see if x is between 2 and 15 (including 2 and 15)?

(x >=2 && x <=15)

In selecting the most appropriate language it is useful to know

*if there is a specific target environment (say, a specific operating system). *how quickly the final code must run. *how much space the final code delivered can occupy.

What are the valid indexes for the array shown below? int myArray[25];

0 - 24

What numbers will the following code display on the computer screen? int x = 0; do { cout<< x <<endl; x=x+1; } while (x < 5);

0,1,2,3,4

Given the following code portion, what is the final value of sum? int sum = 0 ;for (int i=0 ; i < 5 ; i++){sum = sum + i;}cout << sum << endl;

10

How many times is "Hi" printed to the screen for (int i=0 ; i<10 ; i++) { cout <<"Hi \n"; }

10

How many times the following code prints "Computer"?int count = 0;while (count < 10){ cout << "Computer "; count++;}

10

How many times is "Hi" printed to the screen for (int i=0 ; i<=10 ; i++) { cout <<"Hi \n"; }

11

What is the output of the following code:int x[5] = {120, 200, 16};for (int i = 0; i < 5; i++) { cout << x[i] << " ";}

120 200 16 0 0

If you declare an array double list[4] = {3.4, 3.0, 3.5, 5.5}, list[1] is ________.

3.0

How many times will the computer print N in the following code? for (int N = 1; N < 10; N = N + 2) { cout << N << endl; }

5

How many times is "Hi" printed to the screen for (int i=1 ; i<10 ; i++) { cout <<"Hi \n"; }

9

To assign value to a declared variable in C++, programmer should use:

=

Boolean equality operator symbol is:

==

int A [ 20 ]; The fifth element index address is:

A [ 4 ]

What is wrong with the following code fragment? float scores[5]; for(int i=0; i<6;i++) { cout << "Enter a score\n"; cin >> scores[i]; }

Array indexes must be less than the size of the array

Function _______: is using the function in the main.

Call

Function _______: is informing the compiler about your function.

Declaration

Function _______: is writing the actual code of a function.

Definition

What is the third step of the system development life cycle?

Design

The flowchart shape for a binary decision is a(n) _______

Diamond

If X has the value of 60, what will the following code display? if (X > 60) cout << "Pass"; else cout << "Fail";

Fail

T/F Information System Development step: is developing a program specification, defining user requirements, and recommending a plan of action.

False

T/F The following array declaration is legal int grades[ 5 ]={0.1, 5.7, 0.2, 9.2, 0.3};

False

T/F: For loop is used to repeat single statement only.

False

T/F: If the task requires creative thoughts and human touch, then that makes the task candidate for automation.

False

T/F: If there is no default label in switch, an error message will appear.

False

T/F: In do-while loop, the boolean expression is checked before the body has been executed

False

T/F: In while loop, the boolean expression is checked after the body has been executed

False

T/F: Most of the lines in C++ program end with this sign ' } '

False

T/F: The break statement ends the whole program

False

T/F: The original program in a high level language called object code

False

T/F: The result of pow(2,3) is the same as pow(3,2).

False

T/F: The standard set of vocabulary for pseudocode is specific and detailed.

False

T/F: The translated program in machine language called source code

False

T/F: The variables you pass to the function when the function is called are : parameters.

False

T/F: char letters[15]; The index of the last element in the array is: 15

False

T/F: cin and cout are two terms of the same meaning

False

T/F: int Quiz [4] ; It is legal to assign 6.5 to the first element in the array as below: Quiz [ 0 ] = 6.5 ;

False

T/F: with cout, you can output variables values only.

False

T/F:The elements of an array must be integers.

False

\t is used with cout to insert a new text

False

______ includes data, people, procedures, hardware, and software that help achieving a common goal

Information System

What is the sixth step of the system development life cycle?

Maintenance and Evaluation

Which of the following is true for a void function?

Nothing is returned.

The flowchart shape for a terminate is a(n) _______

Oval

If X has the value of 60, what will the following code display? if (X >= 60) cout << "Pass"; else cout << "Fail";

Pass

What is the first step of the system development life cycle?

Problem and Opportunity Identification

What is the fifth step of the system development life cycle?

Testing and Installation

T/F: A variable is a memory address where data can be stored and changed

True

T/F: For loop is good for numeric calculations

True

T/F: Functions may have no value to be returned in some cases.

True

T/F: The following array declaration is legal double scores[ 3 ]={0.1, 0.2, 0.3};

True

T/F: The following two expressions are the same: x1+x2*x3 x1 + x2 * x3

True

T/F: The variables in the function declaration and definition are called parameter

True

T/F: \t is used with cout to insert a tab

True

T/F: function naming rules follow variable naming rules

True

T/F: int x[20]; The index of the last element in the array is: 19

True

T/F: switch statements can be converted into nested if-else statements

True

To display the output in a new line in C++, the programmer should use:

\n

The condition in the do-while loop is written _____________________ the loop body.

after

What C++ variable type should be used in the program deceleration for the following value ( ' k ' )

char

Which of the following lines correctly reads a value from the keyboard and stores it in the variable named myFloat?

cin >> myFloat;

The C++ keyword that used to display output on the screen is:

cout

To output X value

cout >> X;

Which of the following is a legal call to the displayOutput function?void displayOutput(int total);

displayOutput(myTotal);

Which loop type always executes at least once?

do-while

iostream is to end the main function

false

What C++ variable type should be used in the program deceleration for the following value ( 0.099 )

float

What C++ variable type should be used in the program deceleration for the following value ( 3.59 )

float

Declare float array of five elements, then ask the user to input the values of the elements. Choose the correct code portion.

float arr[5]; for (int i=0; i<5; i++) { cin>>arr[i]; }

If you need to write a function that will compute the cost of some candy, where each piece costs $ 1.5, which would be an appropriate function declaration?

float calculateCost(int count);

To assign the value (8.96) in C++ variable, the variable type should be:

float or double

Which of the following statements can be used to code a loop whose statements you want repeat 10 times?

for while all of the answers do - while

Which of the following will ask the user to input all the elements of the array? (Assume the size of the array is 10). cin >> array; for(i=0 ; i < 10 ; i++) cin >> array[10];

for (i=0 ; i < 10 ; i++) cin >> array[i];

Loops in C++ such as:

for, while and do-while

C++ is :

high-level language

Which of the following are allowed in the third section of the for loop statement?

i=i+2 any of the answers i++ i-- i=i-1

If X has the value of 60, what will the following code display?

if (X < 60) cout << "Fail"; else cout << "Pass";

To compare two values, this is the correct statement:

if (X1 == X2)

What C++ variable type should be used in the program deceleration for the following value ( - 5 )

int

What C++ variable type should be used in the program deceleration for the following value ( 3 )

int

To assign values to integer array called children, which line is the correct one?

int children[ 3 ] = { 2 , 12 , 1 } ;

What is the output of the following code fragment if x is 15? if(x < 20) if(x <10) cout << "less than 10 "; else cout << "large\n";

large

When an action must be repeated, a ........... is used.

loop

The language that uses only 0s and 1s is :

machine language

Which of the following are valid function calls to the pow function?

pow(1.5 , 3.0);

in C++, % operator gives the result of:

remainder

Which of the following is not a valid variable name?

return

This variable name is not valid in C++:

sales-total

Given an array named scores with 25 elements, what is the correct way to access or use the 25th element?

scores[24]

Which of the following is a valid variable name?

tax3

In while loop, the Boolean expression is evaluated, If true:

the body of the loop is executed

In while loop, the Boolean expression is evaluated, If false:

the program skips to the line following the while loop

To use cin and cout in your program, you need first:

to include iostream and to use namespace std

In ................... loop, there might be cases when the loop should not run.

while

x ++ means:

x = x + 1

x -- means:

x = x -1


Conjuntos de estudio relacionados

Unit 4B: Political Parties & Influencing Elections

View Set

Functional Anatomy Exam 1 Questions

View Set

ECON chapter 3 guided reading (lesson 1)

View Set

Data and Computer Communications - Final

View Set

Science Test (Last one for the year!!!) (the defs. are from the book)

View Set

Intro to Sociology: Ch.13-16(Exam 3)

View Set

Envir. Sci. Ch 8 Understanding Populations Test (with potential answers) Tolbert

View Set

Cosmetology pivot point chapter 14

View Set

CC4A Translational Motion - Physics 1: Kinematics and Dynamics

View Set

Weather Maps and Cloud Formation

View Set