Question

Question{04}: Which statement is true about "if" and "switch" statements? A. they can be used to...

Question{04}: Which statement is true about "if" and "switch" statements?

A. they can be used to control the flow of your code

B. they can use combinations of logicals in their expression

C. in some situations, they can be used interchangeably

D. they can be used to selectively run lines of code based on a condition

or expression

E. all of the above

Answer{04}='';

Reason{04}='';

Question{05}: Which statement is true about the "else" and "otherwise"

A. an "else" is not required

B. they can be used to "handle" unexpected situations

C. an "otherwise" is not required

D. they both imply false (or that none of the previous expressions have

evaluated to true

E. all of the above

Answer{05}='';

Reason{05}='';

Question{06}: Which statement is true about a "for" loop?

A. its values are limited to only integer values

B. it can not be used to iterate (or loop) through characters/strings

C. it is best used when the number of loops is unknown (at design time)

D. it may be "nested" to allow for looping through multi dimensional

arrays

E. none of the above

Answer{06}='';

Reason{06}='';

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

Answer{04}=E

Reason{04}=IF and SWITCH both are control statements which are used to control the flow of the

program.

They both takes any type of logical combination in their expression.

Both can be used interchangeably for example lets see example below:

if(option == 1) // Checking if user selected option 1

{

//perform some operations

}

if(option==2)

{

//perform operation

}

above code can also be written as follow:

switch(option)

{

case 1:

//perform some operation

break;

case 2:

//perform some operations

beak;

}

Answer{05} D

Reason{05}= they both imply false (or that none of the previous expressions have

evaluated to true.they are not used to handle unexpected siyutaions. in that case

we use exception handling.Both else and otherwise are required in case previous statement evaluated false;

Answer{06} D

Reason{06}=for loop can be used to loop over String . by accessing one character at atime.

It is best when no of loops is known. In case loops are unknown we must

prefer while loop. So all three A,B,C are wrong. Yes D option is right because

it may be "nested" to allow for looping through multi dimensional

arrays

for(int i=0;i<10;i++)

{

for(int j=0;j<10;j++)

{

printf(%d %d,i,j)

}

}

Add a comment
Know the answer?
Add Answer to:
Question{04}: Which statement is true about "if" and "switch" statements? A. they can be used to...
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
  • Form B 29. Which of the following statements about the continue statement is true a. The...

    Form B 29. Which of the following statements about the continue statement is true a. The continue statement is used to exit a repetition structure early and continue the execution of the statements following the loop. b. The continue statement is used to continue after a switch statement c. The continue statement does not alter the flow of control d. A continue statement proceeds with the next iteration of the immediately enclosing loop. e. None of the above 30. Inside...

  • 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 (...

  • 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...

  • Which of the following is a true statement about loops in C++? A) there are 4 loop statements

    Which of the following is a true statement about loops inC++? A) there are 4 loop statements B) there are 2 loop statements C) there are 3 loop statements D) there are infinite loop statements 25. Which of the following is a true statement about loops inC++? A) while and do...while are most commonly used for countercontrolled loops B) while and do...while are most commonly used for variablecontrolled loops C) while and do...while are most commonly used for event controlledloops...

  • Question 10 (3 points) Which of the following statement is not true? There is a recursive...

    Question 10 (3 points) Which of the following statement is not true? There is a recursive sum method as shown below. When sum (19) is called, summation of all odd numbers less than 19 will be calculated and returned public int sum(int x){ if (x == 0) return 0: else return sum(x-2) + x; The following code segment will throw a testException. This exception has been handled in the way that do nothing but to continue when this exception happens....

  • Q18. Which of the following statement is true about tropic savanna climate (Aw)? A, In northern...

    Q18. Which of the following statement is true about tropic savanna climate (Aw)? A, In northern hemisphere, Aw climate has wet summer and dry winter. B, In southern hemisphere, Aw climate has dry summer and wet winter. C, In northern hemisphere, you can expect a lot of precipitation in January. D, In southern hemisphere, you can expect a lot of precipitation in July. E, None of the above is correct. - Q19. Which of the following statement is true about...

  • 1) Which of the following is NOT true about a Python variable? a) A Python variable...

    1) Which of the following is NOT true about a Python variable? a) A Python variable must have a value b) A Python variable can be deleted c) The lifetime of a Python variable is the whole duration of a program execution.   d) A Python variable can have the value None.        2) Given the code segment:        What is the result of executing the code segment? a) Syntax error b) Runtime error c) No error      d) Logic error 3) What...

  • QUESTION 7 Which of the following is a valid C++ assignment statement? (assume each letter is...

    QUESTION 7 Which of the following is a valid C++ assignment statement? (assume each letter is a different variable) A.y=b-c B.y +z = x C.x = a bi D.x = -(y*z): Ex = (x + (y z): QUESTION 8 Which of the following is a valid variable name according to C++ naming rules? A 2ndName B.%Last_Name C@Month D#55 Eyear03 QUESTION 9 Which library must be included to enable keyboard input? A kbdin B. cstdlib C input Diostream E lomanip QUESTION...

  • 41. Which of the following statement is/are true about calcium? A. Intracellular calcium levels are about...

    41. Which of the following statement is/are true about calcium? A. Intracellular calcium levels are about 10X less than extracellular calcium levels. B. Calcium binds to calmodulin, and together they activate a variety of proteins, including myosin light chain kinase. C. Calcium acting in conjuction with diacylglycerol activates protein kinase A D. All of the above are true. E. None of the above is true.

  • 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...

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
ADVERTISEMENT