Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1 Not yet answered Marked out of 2 Flag question Question text The stat

ID: 3662844 • Letter: Q

Question

Question 1

Not yet answered

Marked out of 2

Flag question

Question text

The statement:

loop += count--;

has the same effect as the statements:

count = count+1;
loop = loop - count;

Select one:

a. FALSE

b. TRUE

Question 2

Not yet answered

Marked out of 2

Flag question

Question text

Due to the way computers represent floating point numbers, not every number on the number line can actually be stored into a variable of type double or float.

Select one:

a. TRUE

b. FALSE

Question 3

Not yet answered

Marked out of 2

Flag question

Question text

"Keywords" are reserved names (such as if or while) that cannot be used by programmers as the name of variables, constants or functions.

Select one:

a. TRUE

b. FALSE

Question 4

Not yet answered

Marked out of 2

Flag question

Question text

When C++ evaluates the expression:

if (a < 3 && b > x && c != 12) { ... }

when a equals -1, C++ will short-circuit, report the answer as true,not evaluate the entire logical expression to determine the answer and run the statement block inside the { }s.

Select one:

True

False

Question 5

Not yet answered

Marked out of 2

Flag question

Question text

Within a C++ program, all variables regardless of their type go thru a "life-cycle" which includes declaration, initialization, usage and finally dying off when the variable falls out of scope.

Select one:

a. TRUE

b. FALSE

Question 6

Not yet answered

Marked out of 2

Flag question

Question text

In C++, the body of a for loop will always run atleast once.

Select one:

a. FALSE

b. TRUE

Question 7

Not yet answered

Marked out of 2

Flag question

Question text

C++ programs are case-sensitive.

Select one:

a. FALSE

b. TRUE

Question 8

Not yet answered

Marked out of 2

Flag question

Question text

When a function wants to return more than one value, it must use pass-by-reference parameters to return some of the data back to the calling program.

Select one:

True

False

Question 9

Not yet answered

Marked out of 2

Flag question

Question text

In C++, the body of a do-while loop is always guaranteed to run atleast once.

Select one:

a. FALSE

b. TRUE

Question 10

Not yet answered

Marked out of 2

Flag question

Question text

One difference between a declared variable and a declared constant is that a variable’s value can vary at run-time, but a declared constant’s value cannot be changed after it is initialized.

Select one:

True

False

Question 11

Not yet answered

Marked out of 2

Flag question

Question text

A function may accept either pass-by-reference or pass-by-value parameters, but not both in the same function.

Select one:

True

False

Question 12

Not yet answered

Marked out of 2

Flag question

Question text

In C++, when double variables are left uninitialized, their initial value will not equal zero.

Select one:

a. FALSE

b. TRUE

Question 13

Not yet answered

Marked out of 2

Flag question

Question text

When working with floating-point numerical values, programmers must use care because floating-point numerical representations are always inexact.

Select one:

True

False

Question 14

Not yet answered

Marked out of 2

Flag question

Question text

When working with an if statement, an else clause is optional.

Select one:

True

False

Question 15

Not yet answered

Marked out of 2

Flag question

Question text

The logical expression: ( x >= y ) executes the same as the logical expression: ( x > y && x ==y ).

Select one:

a. TRUE

b. FALSE

Question 16

Not yet answered

Marked out of 2

Flag question

Question text

Pam the Programmer wants to ensure that a few lines of code are only run when a certain circumstance occurs. Which kind of statement should she use?

Select one:

a. a do-while loop

b. an assignment statement

c. an if statement

d. None of the choices below are correct

Question 17

Not yet answered

Marked out of 2

Flag question

Question text

Commenting your C++ code is very important because

Select one:

a. very often, a programming project involves many individuals who will want to understand how your code works, even though you were its sole author

b. a few days after you first write it, you might need to make changes and will have lost your train of thought unless you explicitly state what you are trying to do

c. All of the choices listed are correct

d. many years from now, it might need to be maintained by someone else who will not know what you meant your code to do

Question 18

Not yet answered

Marked out of 2

Flag question

Question text

In the computation: a = b * c + f / g;

C++ will calculate the answer by performing

Select one:

a. the addition and division first, followed by the multiplication and subtraction

b. the subtraction and addition first, followed by the multiplication and division

c. the division and subtraction first, followed by the multiplication and addition

d. the multiplication and division first, followed by the addition and subtraction

Question 19

Not yet answered

Marked out of 2

Flag question

Question text

When using a return statement, the parenthesis around the value being returned to the calling program are

Select one:

a. never allowed

b. required

c. optional

d. required only in certain circumstances

Question 20

Not yet answered

Marked out of 2

Flag question

Question text

Consider the expression: &&( false !( true || false )

Select one:

a. Due to run-time errors, this expression cannot be evaluated

b. At run-time, this expression evaluates to the value true

c. At run-time, this expression evaluates to the value false

d. Due to syntax errors, this expression cannot be compiled successfully

Question 21

Not yet answered

Marked out of 2

Flag question

Question text

Each statement in C++ ends with a

Select one:

a. semicolon (that is a ;) and more than one statement can be present on a single textual line of code

b. semicolon (that is a ;) and only one statement can be present on a single textual line of code

c. pound sign (that is a #) and more than one statement can be present on a single textual line of code

d. new line and only one statement can be present on a single textual line of code

Question 22

Not yet answered

Marked out of 2

Flag question

Question text

When evaluating a complex expression that lack parenthesis such as

x = a + b - c * d / e + f;

C++ will always calculate the answer running + and - before * and / computing the answer as if the user entered

x = (((a + b) - c) * d) / (e + f);

Select one:

True

False

Question 23

Not yet answered

Marked out of 2

Flag question

Question text

Which statement does a function use to send a value back to the calling program?

Select one:

a. A return statement

b. A while statement

c. A exit statement

d. A #include statement

Explanation / Answer

a) False because

loop += count --;

will expand as follows while running:

loop = loop + count --;

which in turn will expand to:

count = count -1;

and then,

loop = loop + count;

hence

count = count+1;
loop = loop - count;

is false

Question 2:

It is partly True, because floating point numbers cannot represent all; The (Institute of Electrical and Electronic Engineers) IEEE – 754 floating point standard recommends the following specification for 32 bit float:

bits 0 to 22: all Ms (Mantissa part)

Bits 23 to 30 : all Es (Exponent part)

Bit 31: Sign bit

For example, the excess-127 binary notation the binary equivalent of decimal 127 =

Certain compilers like Java raises a Not a Number (NAN) error upon encountering such non represent able numbers

The way of internal representation:

Significant Bit * Base raised to the power of Exponent

example:

97.542312 is represented as

97.542312 = 97542312 * 10 ^ -6

where 97542312 is the significant,

10 is the base and

-6 is the exponent

Another example:

657.23 = 65723 * 10 ^ -2


Question 3:

very true

Example for keywords:

int, float, double, for, if, while, do, until, static, public, private, friend, void, and so on and so forth

if you declare a variable like int i,j,k; it(the compiler) mayaccept

but if you declare a variable like int if,do; it will report a compiler error

Question 4:

Short circuiting is the compiler technique to save the time and computation resources.

consider true or false

once the left hand side true is evaluated there is no need to evaluate the right hands side

because no matter what is the right hand side, the result will always be true

as true or true = true

true or false = true

true or <do not care> = true

But in the case of an AND it will work in the reverse way but still short circuiting is possible

false and true

false and true = false;

false and false = false

false and <do not care> = false

The answer if FALSE because when a = -1, the expression becomes,

( -1 < 3 AND b >x AND c Not = 12 )

-1 < 3 evaluates to true

true and <some thing> can not be short circuited

if value of a would have been 4 or any thing greater than 3 then short circuiting might have been possible

(4 < 3 = false;

false AND <do not care> = always false

But in our case since the value of a is less than 3, the answer is false ( short circuiting not possible)

Question 5:

very True

Just as a human has a life span of between 90 to 120 years, every variable ( whether static or non static) in a C++ code has scope or a life span.

For exampl, a variable declared inside a function is alive only inside that function - it is unknown outside the function

Example:

function Sum(int a, int b)   {

int sum;

sum = a + b;

cout << sum; // will work ok

}

function Multiply(int x, int y) {

cout << sum; // will report a compiler error - saying variable sum not found

}

False because, for (int i=1; i<value; i++) means start with the index variable i being equal to 1,

test whether i is less than value if so execute the body of the for loop and increment i by 1 and repeat the testing of whether i < value

when value = 5 it will execute the body 5 times, but if value = 1 it will not execute at all ( not even even once )

for example,

#include <iostream.h>            // input output stream header file

#include <stdio.h>      // standard input output header file

#include <stdlib.h>    // standard library header file

//#include <string.h>   // header file with string function

#include <conio.h>     // console input output header file

int main()         // start main

{

int value = 1;

clrscr();

for(int i=1; i<value; i++)

            cout << "   " << i;

return 0; // exit

} // end of main()

The above code will not display anything

hence answer is false as the body of the for loop will not always execute at least once

Question 7:

Yes, True, C++ programs are case sensitive

for example

int j, J ;

are 2 legitimate (legal) variables as upper case J is different from lower case j

Question (7+1):

When a function needs to return more than one value, it has to employ pass (call) be reference mechanism

#include <iostream.h>            // input output stream header file

#include <stdio.h>      // standard input output header file

#include <stdlib.h>    // standard library header file

//#include <string.h>   // header file with string function

#include <conio.h>     // console input output header file

void funcChange(int i, int j, int k)      {

            cout << " inside function called by value i = " << i << " j = " << j << " k " << k;

} // end funcChange

void funcChangeRef(int *i, int *j, int *k)      {

            cout << " inside function called by reference i = " << i << " j = " << j << " k " << k;

} // end funcChangeR

int main()         // start main

{

int value = 1;

clrscr();

for(int ii=1; ii<value; ii++)

            cout << "   " << ii;

funcChange(1,2,3); // call by value

int p=5,q=6,r=7,

funcChangeRef(&p,&q,&r);

return 0; // exit

} // end of main()

the above function changes all the 3 values namely p,q, and r by using call by or pass by reference where the function changes the contents stored in the memory address

Question 9:

False because the do while need not run always once – explanation is the same as the one given above for the for loop

Question 14:

True - else is optional for an if statement

Question 15 true

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote