Question

Evaluate the following expressions and state the type of each expression: int a = 2; int...

Evaluate the following expressions and state the type of each expression:

int a = 2;
int b = 3;
double c = 3.0;

1. b / 2.0

Type: ( double, boolean, decimal, int )?

Value: ( answer )?

2. b ! = 3

Type: ( double, boolean, decimal, int )?

Value: ( answer )?

3. a >= 2.0

Type: ( boolean, double, char, int )?

Value: ( answer )?

Homework Answers

Answer #1

1 -->

b is an integer datatype and value 2.0 is float/double.

when we divide an integer with a flaot, we get answer in float/double.

so, b / 2.0 type will be -> double.

now, when we divide 3 by 2.0 we get 1.5.

Type -> double , Value -> 1.5

2-->

b != 3

this is checking if b is not equal to 3. It is comparing, so its type will be boolean.

now, we have value of b = 3, so,

b != 3 is not true, hence it will give value as 0 (false)

Type -> Boolean , Value -> 0

3-->

a >= 2.0

this is also checking if a is greater or equal to 2.0, so its type will be boolean.

now, we have value of a = 2, so,

a>=2.0 is true, hence it will give value as 1 (True)

Type -> Boolean, Value -> 1

Know the answer?
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
Similar Questions
(1) What are the advantages and disadvantages to using the Int data type rather than the...
(1) What are the advantages and disadvantages to using the Int data type rather than the bool data type to manipulate Boolean expressions? Why do students think the int data type is still used for Boolean expressions? (2) Discuss how C++ provides two-way selection through the if....else statement. Explain the syntax of this statement. Also, explain how the bool data type is used in C++ to manipulate Boolean expressions.
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue = red + 2 * 5 red++; blue = blue + red; cout << blue; 4 points    QUESTION 2 Is the following statement true or false? The Boolean expression in the following if statement will be true for all values of x in the range from 10 to 20 (including the endpoints) and false for all other values: int x; if (x >=...
Classify each of the following expressions as legal or illegal. Each expression represents a call to...
Classify each of the following expressions as legal or illegal. Each expression represents a call to a standard Python library function. (a) math.sqrt(4.5) (b) math.sqrt(4.5, 3.1) (c) random.rand(4) (d) random.seed() (e) random.seed(-1)
Consider the following Boolean expression (a + b) . (a + c). Provide a simpler expression...
Consider the following Boolean expression (a + b) . (a + c). Provide a simpler expression (fewer gates) that is equivalent. Show that your expression is equivalent by building truth tables for both expressions in the same way as we've done before. 1a. Imagine that you have designed a circuit that uses N expressions of the form (a + b) . (a + c). We replace each of these with your solution to question 1. How many fewer transistors will...
(Please answer everything and with explanation) Mathematical expressions that evaluate to even and odd integers. In...
(Please answer everything and with explanation) Mathematical expressions that evaluate to even and odd integers. In the expressions below, n is an integer. Indicate whether each expression has a value that is an odd integer or an even integer. Use the definitions of even and odd to justify your answer. You can assume that the sum, difference, or product of two integers is also an integer. (a) 2n + 4 (b) 4n+3 (c) 10n3 + 8n - 4 (d) -2n2...
Write any 2 C programs of a structure having return type int, char, float. Explain each...
Write any 2 C programs of a structure having return type int, char, float. Explain each step for both the programs. The code should be simple as I am a beginner. Also, I need an urgent answer.
For each of the following, assume that we are using a 32-bit system with single-precision (32-bit)...
For each of the following, assume that we are using a 32-bit system with single-precision (32-bit) floating point numbers (floats) in IEEE format, double-precision (64-bit) doubles in IEEE format, and 32-bit integers. Which of the following evaluate to true for all argument values? (Circle each that is always true). char c = .. int x = .. short y = .. float f = .. double d = .. c == (char)(float) c y == (short)(int) y f == (float)(double)...
4. The _____ case is performed by the switch statement if a match is not found...
4. The _____ case is performed by the switch statement if a match is not found default first second otherwise Answer: 5. When three relational expressions are joined by OR (||) operators, there must be at least _____ of the relational expressions that evaluate to true for the logical expression to evaluate to true. one two three none of the relational expressions evaluate to true Answer: 6. Which of the following items is an acceptable first character in a Java...
For each of the following regular expressions, give 2 examples of strings that are in the...
For each of the following regular expressions, give 2 examples of strings that are in the language described by the regular expression, and 2 examples of strings that are not in that language. In all cases the alphabet is {a,b}. ab*ba* (a ∪ ε)b* (a ∪ b)ε*(aa ∪ bb)
For each of the following regular expressions, give 2 examples of strings that are in the...
For each of the following regular expressions, give 2 examples of strings that are in the language described by the regular expression, and 2 examples of strings that are not in that language. In all cases the alphabet is {a, b}. ab*ba* (a ∪ ε)b* (a ∪ b)ε*(aa ∪ bb)