Question

QUESTION 1 Which statement results in the value false? The value of count is 0; limit...

QUESTION 1

Which statement results in the value false?

The value of count is 0; limit is 10.

(count != 0)&&(limit < 20)

(count == 0)&&(limit < 20)

(count != 0)||(limit < 20)

(count == 0)&&(limit < 20)

10 points   

QUESTION 2

If this code fragment were executed in an otherwise correct and complete program, what would the output be?
int a = 3, b = 2, c = 5
if (a > b)
a = 4;
if ( b > c)
   a = 5;
   else
    a = 6;
cout << a << endl;

5

3

6

4

10 points   

QUESTION 3

Which is incorrect regarding

a void function

performs some action and returns a value

performs some action but does not return a value

is a statement

A void function may have a return statement but is not required to have one.

10 points   

QUESTION 4

Which statement results in the value false?

The value of count is 0; limit is 10.

(count == 0)&&(limit < 20)

(count == 0)&&(limit < 20)

(count != 0)||(limit < 20)

(count != 0)&&(limit < 20)

10 points   

QUESTION 5

Which of the following overloadings will be invoked by this call?

g(1,2);

void g(int value, int count);

void g(double value, int count);

int g(int count, double value);

None listed

10 points   

QUESTION 6

Which is incorrect?

The sqrt function

is provided in the <cmath> library header

the argument type is int

returns the square root of the argument

the return type is double

10 points   

QUESTION 7

A call to a C++ function is

The name of the function followed by exactly the number of arguments as there are parameters in the definition

The name of the function followed by empty parentheses

The name of the function followed by any number of arguments, regardless of the number of parameters in the definition

The name of the function only

10 points   

QUESTION 8

Which is correct?

In a do-while loop, a continue statement terminates the loop

In a while loop, the Boolean_Expression is executed before each execution of the loop body.

When a loop is nested in side another loop, a break or continue statement terminates or restarts the outermost loop of the nested loop structure.

A break statement is used in loops only.

10 points   

QUESTION 9

If this code fragment were executed in an otherwise correct and complete program, what would the output be? .

int a = 3, b = 2, c = 5

if (a > b)

a = 4;

if ( b > c)

a = 5;

else

a = 6;

cout << a < endl;

3

6

5

4

10 points   

QUESTION 10

Which of the following is NOT correct about the || operator?

It uses short circuit evaluation

It returns true if both operands are true

It is the logical OR operator

It can have two operands

10 points   

QUESTION 11

Which control construct repeats a sequence of statements zero or more times?

if-else statement

switch

do -while statement

while statement

10 points   

QUESTION 12

Consider the if statement:

if(condition) yes_clause; else no_clause;

Under which of the following circumstances will both the yes_clause and the no_clause will be executed?

When the condition is false

When the condition is true

This will not happen

When the condition is ambiguous

10 points   

QUESTION 13

Which is incorrect?

The value of count is 0; limit is 10. The following evaluates as true:

(count == 0)&&(limit < 20)

The value of count is 0; limit is 10. The following evaluates as true:

count == 0 && limit < 20

You want to determine whether time has run out. The following code correctly implements this.

            !time > limit

The  if, while and for statements control only one statement.

10 points   

QUESTION 14

Which of the following loop statements is guaranteed to iterate the body of the loop at least once?

while(control) {body};

do {body} while(control)

all listed

for(initialize;test:update){body};

10 points   

QUESTION 15

If the following code fragment is executed in an otherwise complete and correct program, which expression will be executed?

x = 0;

if (x = 12)

yes_statement;

else

no_statement;

The no_statement will be executed because x is not 12.

The statement has incorrect syntax so will not compile at all

The yes_statement will be executed.

x=12 is illegal in the Boolean expression of an if statement

10 points   

QUESTION 16

When you don’t recall operator precedences you can

Look in a table of precedences

Guess

Use parentheses

Experiment with the compiler

10 points   

QUESTION 17

In distinguishing an expression as true or false, C++ sees which of the following as true?

true

0

Any non-zero value

1

10 points   

QUESTION 18

What is incorrect about the expression below?

left && right

The expression is true when left is true and right is true

The expression is false when left is false and right is false

The expression is true when left is true and right is false

The expression is false when left is false and right is true

10 points   

QUESTION 19

What is incorrect about the following expression?

left || right

The expression is false when left is false and right is true

The expression is true when left is true and right is false

The expression is false when left is false and right is false

The expression is true when left is true and right is true

10 points   

QUESTION 20

Regarding the comma operator, which statement is incorrect?

Results in the value equal to the value of the first expression in the list

ANSI C++ Standard specifies that expressions must be evaluated left to right

Is used to separate a list of expressions

Expressions are evaluated in order defined by the compiler

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Q1. Ans (count != 0)&&(limit < 20)

explaination: count is equal to zero as this is false resot of And operation is false

Q2. it displays 6

first if checks a > b which is true then a becomes 4 , nextx statementr check if b > c which is false so a is assigned value 6

Q3. Ans: performs some action and returns a value

Explaination: void function does not return any value

Q4. Ans:(count == 0)&&(limit < 20)

Q5: Ans: void g(int value, int count);

explaination:since g is called with both input parameters integer , above function is called

Q6: Ans: the argument type is int

Sqrt takes arguments of type double

Q7: Ans: The name of the function followed by exactly the number of arguments as there are parameters in the definition

Q8: Ans:In a while loop, the Boolean_Expression is executed before each execution of the loop body.

Q9: Ans: 6

Q10: Ans: It returns true if both operands are true

Q11: Ans :if-else statement

Q12: Ans :This will not happen

Q13: Ans:The  if, while and for statements control only one statement.

Q14: Ans: do {body} while(control)

Q15: Ans: The yes_statement will be executed.

Q16: Ans: Use parentheses

Q17: Ans:Any non-zero value

Q18: Ans: The expression is true when left is true and right is false

Q19: Ans:The expression is false when left is false and right is true

Q20: Ans: Results in the value equal to the value of the first expression in the list

Add a comment
Know the answer?
Add Answer to:
QUESTION 1 Which statement results in the value false? The value of count is 0; limit...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 21 The loop condition can be a complex condition involving several operators. True OR False...

    Question 21 The loop condition can be a complex condition involving several operators. True OR False Question 22 final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87; if(num3-5 >= 2*LIMIT) { System.out.println ("apple"); } else { System.out.println ("orange"); } System.out.println("grape"); What prints? A. Apple B. Orange C. Grape D. apple grape E. orange grape F. Nothing. Question 23 When we use a while loop, we always know in advance how many...

  • What is the output of the following C++ code? int count = 1; int num =...

    What is the output of the following C++ code? int count = 1; int num = 25; while (count < 25) { num--; count++; } cout << count « " " « num << endl i 25 1 0 24 1 0 25 0 0 24 0 In this while loop statement, while (counter < 10), where counter is an int variable. Which statement below is an equivalent way to write this while statement? while (10 < counter) while (9...

  • Quiz Question 1 (1 point) Saved The maximum value for an int is: Question 1 options:...

    Quiz Question 1 (1 point) Saved The maximum value for an int is: Question 1 options: 2147483647 65535 32767 9223372036854775804 Question 2 (1 point) A float has ____ decimal places of accuracy. Question 2 options: 15 none     7 3 Question 3 (1 point) It is a good practice to compare floats and doubles with ==. Question 3 options: True False Question 4 (1 point) Strings are reference data types. Question 4 options: True False Question 5 (1 point) Value data...

  • QUESTION 1 What will be displayed as a result of executing the following code? int   x...

    QUESTION 1 What will be displayed as a result of executing the following code? int   x = 5, y = 20; x += 32; y /= 4; cout <<"x = " << x <<"y = " << y; A. x = 32, y = 4 B. x = 9, y = 52 C. x = 37, y = 5 D. x = 160, y = 80 8 points    QUESTION 2 What will be the displayed when the following code...

  • java QUESTION 4 Which of the following statements about a do...while repetition statement is true? A....

    java QUESTION 4 Which of the following statements about a do...while repetition statement is true? A. The body of a do...while loop is executed only if the terminating condition is true. B. The body of a do...while loop is executed only once. C. The body of a do...while loop is always executed at least once. D. None of the above QUESTION 5 To exit out of a loop completely and change the flow of control to the first line after...

  • Please Help with the following questions (just true or false, except last one is choose 1)...

    Please Help with the following questions (just true or false, except last one is choose 1) QUESTION 1 Given: int myvar=99; Is this expression true or false? myvar (That is, is the value of myvar, 99, true or false) True False QUESTION 2 Given: int myvar=3; int yourvar=0; Is the following expression true or false? myvar == 3 && yourvar == 0 True False QUESTION 3 Given: int myvar=3; int yourvar=0; Is the following expression true or false? myvar ==...

  • #include<iostream> using namespace std; int main() { float num,avg,sum=0.0; int count=0; bool moreNumbers=true; cout<<"Enter grades:"<<endl; while(moreNumbers)...

    #include<iostream> using namespace std; int main() { float num,avg,sum=0.0; int count=0; bool moreNumbers=true; cout<<"Enter grades:"<<endl; while(moreNumbers) { cin>>num; if(num < 0) { moreNumbers=false; } else { count = count+1; sum=sum+num; } } avg=sum/count; cout<<"Average grade:"<<avg<<endl; cout<<"How many grades were entered:"<<count<<endl; return 0; } Question: We need to add another loop to check input. Just like the input loop we already have, this one should use a boolean variable as a control. So, the logic could be something like this: Loop...

  • Q1: Which of the following is a double-selection control statement? do…while for if…else if. Q2: Which...

    Q1: Which of the following is a double-selection control statement? do…while for if…else if. Q2: Which of the following is not a Java keyword? do next while for Q3: What is output by the following Java code segment? int temp; temp = 200; if ( temp > 90 )    System.out.println( "This porridge is too hot." ); if ( temp < 70 )    System.out.println( "This porridge is too cold." ); if ( temp == 80 )    System.out.println( "This...

  • Question 1 What is the value of x after the following int x = 5; x++;...

    Question 1 What is the value of x after the following int x = 5; x++; x++; x+=x++; A)14 B)10 C)13 D)15 Question 2 The last line in value returning function (before the }) should contain the word return. True False Question 3 This contains three parts: Void or Data Type the name optional parameter list A)Menu System B)Function Header C)Switch Question 4 What is a variable? A)a pointer B)a place in memory to hold data C)int D)a computer programming...

  • # After the if statement that follows is executed, what will the value of $discount_amount be?...

    # After the if statement that follows is executed, what will the value of $discount_amount be? $discount_amount; $order_total = 200; if ($order_total > 200) { $discount_amount = $order_total * .3; } else if ($order_total > 100) { $discount_amount = $order_total * .2; } else { $discount_amount = $order_total * .1; }         2         20         40         60 # To open a file in PHP, you use the _________ function.         fopen()        ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT