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
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)
(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...
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)...
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)
2. Consider the following program written in C syntax: void swap(int a, int b) {   ...
2. Consider the following program written in C syntax: void swap(int a, int b) {    int temp;    temp = a;    a = b;    b = temp; } void main() {    int value = 2, list[5] = {1, 3, 5, 7, 9};    swap(value, list[0]);    swap(list[0], list[1]);    swap(value, list[value]); } For each of the following parameter-passing methods, what are all of the values of the variables value and list after each of the three...
Consider the following two methods: public static boolean isTrue(int n){        if(n%2 == 0)          ...
Consider the following two methods: public static boolean isTrue(int n){        if(n%2 == 0)           return true;        else           return false; } public static int Method(int[] numbers, int startIndex) { if(startIndex >= numbers.length)        return 0; if (isTrue(numbers[startIndex]))      return 1 + Method(numbers, startIndex + 1); else      return Method(numbers, startIndex + 1); } What is the final return value of Method() if it is called with the following parameters: numbers = {1, 2, 2, 3, 3,...
1. Translate the following English expressions into logical statements. You must explicitly state what the atomic...
1. Translate the following English expressions into logical statements. You must explicitly state what the atomic propositions are (e.g., "Let p be proposition ...") and then show their logical relation. a. If it is red then it is not blue and it is not green. b. It is white but it is also red and green and blue. c. It is black if and only if it is not red, green, or blue. 2. Determine if the following expressions are...
2. Given the following declarations, explain why some of the following assignments are incorrect int x...
2. Given the following declarations, explain why some of the following assignments are incorrect int x = 10; char y = 'A'; int *ptr1; char *ptr2 = &y; a. x = y; b. ptr1 = ptr2; c. ptr1 = &x; d. x = &ptr1; e. ptr2 = &x; Thanks.
C++ What is the value of average after the following code executes? double average; average =...
C++ What is the value of average after the following code executes? double average; average = 4.0 + 3.0 * 2.0 + 1.0; Consider the following function: int compute(int n) { int x = 1; for (int i = 1; i <= n; i++) { x *= i; } return x; } What is the returned value for the following function call? int value = compute(4); What is the value of number after the following statements execute? int number; number...