12. if x = 0x25 then which of the following statements is
correct a) if y = x | (1<<1) then y is 0x26 b) if y = x
<< 1 then y is 0x4A
Review questions COMP 2401 Fall 2019
Page 4 of 14
c) if y = x & 0x37 then y is 0x35 d) if y = x | 0x37 then y is
0x35 e) All of the above statements are incorrect
13. What will be the output of the following code segment? int u =
18; int v = 10; if (u && v) printf(“Fall Term!! ”); if (u
& v) printf(“Winter Term!! \n”);
a. Winter Term!! Fall Term!! b.Fall Term!! c. Winter Term!! d. Fall
Term!! Winter Term!! e. None of the above
14. Given the following declaration char x = -11; char y = 63; if
the computer uses 2’s complement to represent the numbers then
which statement is correct: a. The number of bits in x is equal to
the number of bits in y b. The number of bits in x is less than the
number of bits in y c. The number of bits in x is greater than the
number of bits in y d. None of the above
12) Answer is: b) if y = x << 1 then y is 0x4A
Wrong options Output 0
a) y = x |(1<<1); then y will be 0x27
c) y = x & 0x37 then y will be 0x25
d)y = x | 0x37 then y will be 0x37
13)
Answer is: d. Fall Term!! Winter Term!!
Code -
int u = 18;
int v = 10;
if (u && v)
printf("Fall Term!! ");
if (u & v)
printf("Winter Term!! \n ");
Output : Fall Term!! Winter Term!!
12. if x = 0x25 then which of the following statements is correct a) if y...
14. Given the following declaration char x = -11; char y = 63; if the computer uses 2’s complement to represent the numbers then which statement is correct: a. The number of bits in x is equal to the number of bits in y b. The number of bits in x is less than the number of bits in y c. The number of bits in x is greater than the number of bits in y d. None of the...
Question 1Which of the following statements is syntactically correct in C? A) print("Winter is coming."); B) printf("Winter "+"is"+”coming.”); C) printf(Winter is coming.); D) printf("Winter is coming."); E) None of the Above Question 2 What is the percent code used in scanf for an character? A) %c B) %f C) %d D) %lf E) None of the Above Question 3 What is the value of the following arithmetic expression? 80 – 3 * 12 + 21 / 3 A) 315 B) 37 C) 47 D) 24 E) None of...
which of the following i.. INVALID identifier in C? A. hot do 1 B. 2ab С.cat1 D. pri 2. Assuming int an, boos which of the following statement avigns b a different value from others A. b a/2 B. b-64--a) D. b a>372:1 3. What's the correct output of the following code int m-1 printtoidm-2) A. 000 B. 123 C. 012 D. None of above 4. What's the output of following code: char str [15]."hello!"; printf( idin",strlen(str)) A. 6 B....
12. Which of the following statements is (are) correct? (x) The legal tender requirement by the U.S. government means that people are more likely to accept the U.S. dollar as a medium of exchange. (y) Since the U.S. government has decreed that U.S. currency is legal tender, the government must hold enough gold to redeem all currency. (z) The set of items that serve as media of exchange clearly includes credit cards and short-term bonds. A. (x), (y), and (z)...
1. Every C++ program must have: A. a cout statement B. function main C. a #include D. All of the above 2. main() is a method that is part of the ‘Standard Library’. T__ F__ 3. Inside a ‘Console Application’, a ‘Project’ may implement multiple ‘Solutions’. T__ F__ 4. The C++ source-code files are listed with the extension .sln. T__ F__ 5. It is recommended to start...
1. Minimum number of gates needed to implement (x + ~x * y )(~x + x*~y) Note: ~ means not. Simplify to get the minimum cost. ------------------------------------- 2. Simplify and find the minimum number of gates needed to implement ~((x + ~x * y )(~x + x*~y)) a. 1 b. 2 c. 3 d. 4 e. 5 -------------------------------------- 3. The number of different signed 2's complement numbers representable using 4-bits? a. 18 _b. 17 _c. 16 _d. 15 _e. 14 -----------------------------------------...
Consider the following method: public static int mystery (int x, double y, char ch) { int u; if ('A' <= ch && ch <= 'R') return (2 * x + (int)(y)); else return((int)(2 * y) - x); } What is the output of the following Java statements? a. System.out.println (mystery(5, 4.3, 'B')); b. System.out.println (mystery(4, 9.7, 'v')); c. System.out.println (2 * mystery(6, 3.9, 'D'));
4. What is stored in each frame? Circle all the correct answers a. Local variables b. Static variables c. Return address d.Function parameters e. Global variables f. Function code 5. A union is a data type that A. can only be declared inside a struct type B. is useful for constructing linked lists C. can only be used with arrays D. reserves the same space of memory for its fields E. None of the above ...
9. Which of the following is true for the following program? #include <stdio.h> int maino int i = 1; switch (0) case 1: printf("%d", 0); case 2: printf("%d", 0); case 3: printf("%d", 0); default: printf("%d", 1); return 0; } (2 points) The program has no error, the output is 1111 The program has no error, the output is 1 The program produces a compile time error, because there are no break statements The program produces a compile time error, because...
main.c #include <stdio.h> int main() { Tong Tong int x = 1234567890000; char y = (char) x; printf("%d\n", y); Compile and run the above main.c file. a) Indicate the compiler command you would use to compile this program. Do any of the following flags affect the compilation? -Wall -Werror -pedantic -Woverflow b) Indicate any discrepancy between expected and actual behavior, and as a programmer, how to construct best practices to avoid this deviation. c) What happens if we do not...