Question

In: Computer Science

1. Which of the following can be treated as a Boolean expression? A. an int expression...

1. Which of the following can be treated as a Boolean expression?

A. an int expression
B. any of these
C. the result of a comparison(such as <or>)
D. a float expression

2. Assuming the variable x contains an integer value what will the result of the following statement be: if x<0 or x>=0.

A. True
B. False
C. Sometimes true and sometimes false
D. A "math domain" error will occur

Solutions

Expert Solution

1. Which of the following can be treated as a Boolean expression?

A. an int expression

B. any of these

C. the result of a comparison(such as <or>)

D. a float expression


ANSWER: B

Explanation:

Boolean data type is return either True or False. It's a logical statement. Boolean expression can compare any type of data but the condition is that the expression have the same basic data type. you can perform expression like a<=b , a.=b , a!=b , less than, greater than etc...

Let's talk of your quetion:

Here option A an int expression lets take an example

Suppose we have two int value 5 and 6 we want to check is equal or not. so we can write like this

5==6

it's return FALSE because 5 is not equal to 6. So option A is correct.

option c

Suppose we have two int value 10 and 16 we want to check is less than or not. so we can write like this

10<16

it's return TRUE because 10 is less than to 16. So option c is also correct.

option D

Suppose we have two float value 0.1 and 1.6 we want to check is equal or not. so we can write like this

0.1==1.6

it's return FALSE because 10 is less than to 16. So option D is also correct.

So the ans is B any of these.

2. Assuming the variable x contains an integer value what will the result of the following statement be: if x<0 or x>=0.

A. True

B. False

C. Sometimes true and sometimes false

D. A "math domain" error will occur

ANSWER: A

Explanation:

Lets take example here we first take x=0 so its return TRUE

Now we take x=1 so its return TRUE

Now we take negative value which is x = -5 It's also return TRUE

Here you take whatever value its always return TRUE because here in if statement give OR so it's check if any one condition either x<0 or x>=0 is satisfied it Return TRUE.

so the answer of your question is option A


Related Solutions

1.) Simplify the following Boolean Expression to a minimum number of literals. (a'b' + c)(a +...
1.) Simplify the following Boolean Expression to a minimum number of literals. (a'b' + c)(a + b + c') a.)ab + a'b'c' + ac b.)ac + abc + bc c.)ac + a'b'c' + bc d.)a'c + abc + b'c e.)None of the above 2.) Reduce to two literals. wxy'z + w'xz + wxyz a.) xz b.) x'z c.) xz' d.) yz e.) None of the above
(A) Minimize the following Boolean expression as much as possible and Design the obtained function with...
(A) Minimize the following Boolean expression as much as possible and Design the obtained function with NAND universal logic gates Y = AB + A(B+C) + B (B+C) (B) Design a logic gate circuit diagram ( combination circuit ) that accepts a 3 - bit BCD number and generates an output binary number equal to the square of input number.
Lithium Overdose can be treated with which of the following,
Lithium Overdose can be treated with which of the following,
public boolean areArrays(int[] arr1, int[] arr2){ // 1. initial check: both arrays need to have the...
public boolean areArrays(int[] arr1, int[] arr2){ // 1. initial check: both arrays need to have the same length, return false if not the same // 2. return true if both given arrays are equals(same values in the same indices), false otherwise if(arr1.length != arr2.length){ return false; } for(int i = 0; i < arr1.length; i++){ if(arr1[i] != arr2[i]){ } } return true; } public int getIndexOfWord(String[] arr, String word){ // if found, return the index of word, otherwise return -1...
Write a simplified expression for the Boolean function defined by each of the following Kmaps. 00                   ...
Write a simplified expression for the Boolean function defined by each of the following Kmaps. 00                    01                 11 10 YZ 0 1 1 0 1 0 0 1 X 0 1 00                    01                 11 10 YZ 0 1 1 1 1 0 0 0 X 0 1 00                    01                 11 10 YZ 1 1 1 0 1 1 1 1 X 0 1
Consider the following two methods: public static boolean isTrue(int n){ if (n <= 1)          return false;...
Consider the following two methods: public static boolean isTrue(int n){ if (n <= 1)          return false;        for (int i = 2; i < n; i++){          if (n % i == 0)             return false; }        return true; } 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...
Write function boolean isSorted(int a[], int size). The function returns true if array a is sorted...
Write function boolean isSorted(int a[], int size). The function returns true if array a is sorted in either ascend order or descend order; false otherwise. c++
3.a Draw the logic diagram for the following Boolean expression. The diagram should correspond exactly to...
3.a Draw the logic diagram for the following Boolean expression. The diagram should correspond exactly to the equation (do not simplify). Assume that the complements of the inputs are available. ? = ?′?(? + ?) + ??′(? + ?) + ?′?(? + ?) + ??′(? + ?) b. Simplify the Boolean expression in (a) using a Karnaugh Map, then draw the corresponding two-level logic diagram as a sum of products implementation.
Use Logisim to minimize the following Boolean expression: x’yz’ + x(y + z’)’ + xyz
Use Logisim to minimize the following Boolean expression: x’yz’ + x(y + z’)’ + xyz
For each comparison, indicate (1) proper subtraction order and (2) boolean expression of flag values that...
For each comparison, indicate (1) proper subtraction order and (2) boolean expression of flag values that are true if the condition is satisfied. Be sure to justify your answers. Example:   Signed A == B ;   (1) either A-B or B-A, (2) Z==1 Signed A != B
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT