Question

C++ 1)Define a boolean variable and initialize it to true. 2) On the next line, display...

C++

1)Define a boolean variable and initialize it to true.
2) On the next line, display the value of the boolean variable.
Example: The value of true is x
3) Set the above boolean value to false.
4) On the next line, display the value of the boolean variable.
Example: The value of false is x

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

here is the C++ code for the following problem --

#include "iostream"

using namespace std;

int main(){

bool var = true; // step 1

cout << var << "\n"; // step 2

var = false; // step 3

cout << var << "\n"; // step 4

return 0;

}

Add a comment
Know the answer?
Add Answer to:
C++ 1)Define a boolean variable and initialize it to true. 2) On the next line, display...
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
  • [C++] Declare three Boolean flags and initialize it as with false value. Ask the user to...

    [C++] Declare three Boolean flags and initialize it as with false value. Ask the user to enter a number, if the number is even make the first flag true, if the number is odd make the second flag true, and if the value entered by the user was not a number make the third flag true. Print out the values of the three flags along with a proper message telling the user about what he/she entered.

  • this is java 4. (2 point each) What value will be assigned to the "answer" variable...

    this is java 4. (2 point each) What value will be assigned to the "answer" variable below? If the expression will not compile in Java, explain why. Write your answer on the line to the right. a. boolean answer = 6 < 2 || 7 > 3; b. boolean answer = true && false; c. boolean answer = ! (87 == 80); d. boolean answer = true > false; e. String name = "Daniel" ; boolean answer = ! (name.equals("Charles"));...

  • C language not C++ 1. Write the statements to do the following: (2 pts) a. Define...

    C language not C++ 1. Write the statements to do the following: (2 pts) a. Define a struct with member variables width, height, topleft x, topleft y all floats). Use a tag to call it Rectangle. b. Declare a variable struct type Rectangle 2. Consider the following variables: struct int x; float y; char zi var1; union nt x; float y; char[20] z;) var2 f float and int are stored using 4 bytes each, what is the size (in bytes)...

  • Given a boolean variable a, are the following expressions equivalent? !( !a ) a 1) No...

    Given a boolean variable a, are the following expressions equivalent? !( !a ) a 1) No answer text provided. 2) true 3) false 4) No answer text provided.

  •    /**    * Returns an array of booleans that are set true or    *...

       /**    * Returns an array of booleans that are set true or    * false based on the associated values in the array    * arr using the following rules:    * 1. If arr[i] is divisible by three then the boolean    * value in the the array returned at the same position    * should be true    * 2. Unless the values in arr[i] is also divisible by 5,    * then the value returned...

  • C++ pointers and linked lists 1. Declare an integer pointer variable intPointer. Initialize it to point...

    C++ pointers and linked lists 1. Declare an integer pointer variable intPointer. Initialize it to point to an int variable named someInt. Assign the value 451 to someInt and output (cout) the variable someInt and output (cout) the value pointed to by intPointer. Write an assignment statement that indirectly stores 900 into the value pointed to by intPointer. Output (cout) the value pointed to by intPointer and output (cout) the variable someInt, 2. Declare a pointer variable charArrPointer and initialize...

  • Question 1 True and False are Boolean keywords in Python True False Question 2 0.0/1.0 point...

    Question 1 True and False are Boolean keywords in Python True False Question 2 0.0/1.0 point (graded)       hot_plate = True if hot_plate:     print("Be careful, hot plate!") else:     print("The plate is ready.") The output of from running the above code is ___ "Be careful, hot plate!" "The plate is ready." "True" NameError Question 3 0.0/1.0 point (graded)       vehicle_type = "Truck" if vehicle_type.upper().startswith("P"):     print(vehicle_type, 'starts with "P"') else:     print(vehicle_type, 'does not start with "P"')     The...

  • 2. Part 1 of 2- Select the correct Boolean value of the variable result in the...

    2. Part 1 of 2- Select the correct Boolean value of the variable result in the following code. d = dict(A = 'a', B = 'b') result = 'a' in d A. True B. False 2. Part 2 of 2- Identify the syntax to declare an empty dictionary in Python. A. d = dict("empty") B. d = [] C. d = {} D. d = [:]

  • public static boolean primeCheck (int num) int temp; boolean isPrime-true: for(int i-2;i<=num/ 2 ; i++) temp-numsi...

    public static boolean primeCheck (int num) int temp; boolean isPrime-true: for(int i-2;i<=num/ 2 ; i++) temp-numsi if (temp=-0) isPrime-false; break; return isPrime Given the above code segment, 1. (30 points) Draw a Control Flow Graph (CFG) for the code. 2. (10 points) Enumerate the Test Requirements for node coverage. Design a set of 3. 4. 5. test cases (input value num) that will satisfy node coverage. (10 points) Enumerate the Test Requirements for edge coverage. Design a set of test...

  • You are given a boolean expression consisting of a string of the symbols 'true', 'false', and', 'or', and 'xor'.

    [III.4] You are given a boolean expression consisting of a string of the symbols 'true', 'false', and', 'or', and 'xor'. Count the number of ways to parenthesize the expression such that it will evaluate to true. For example, there is only 1 way to parenthesize 'true and false xor true' such that it evaluates to true. Complete the following tasks.  [III.4a] Show the parenthesization of the example such that evaluate to true.   'true and false xor true' [III.4b] Show the optimal substructure...

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