Question
1. int a = 10, b, c, d; a. compute d = b = c = a b. compute d = a / 3 c.
1. int a = 10, b, c, d;
a. compute d = b = c = a
b. compute d = a / 3
c. compute d = a%3
2. int a = 10, b;
a. compute b = a/3
3. What is y displayed in the following code?
#include
int main()
{ int x = 1; int y = x = x - 1;
cout << "y is " << y;
return 0;
}
4. int a =10, b = 20; c = 10, d;
a. compute d = (++a) + b c
b. compute d = a (b--) + (++c)
5. int a = 10, b = 11, c = 167, d; (Take 8-bit binary representation)
a. compute d = a&b
b. compute d = a|(b&c)
c. compute d = (a==b)
d. compute d = (a>=b)
e. compute d = ((a&b)|c)
f. compute d = (a&(~b))
6. What will be the value of the variable d in the statement given below if x, y, and z are int variables, and x = 10, y = 15, and z = 20. You can give the results in 1 and 0 or true and false (true means 1 and false means 0).
d = (x <= z % y - 2) && (y >= z)
7. int a = 100, b = 11, c;
a. compute c = a<<2
b. compute c = b<<2
8. Suppose that x = (2B6E)16 , y = (5AE9)16 and Z = (27BC)16 and Solve the expression = (x|~y&~z) and return the result in hexadecimal.
9. int a = 110, b = 10, c;
a. compute c = (a==100) ? b : a
10. int a = 100, b = 10, c = 34; d;
a. compute d = (a / b)* c + ((c *b) a) / b
b. compute d = (a % b)* c + ((c *b) a) / b
c. compute d = (a / b)* c - ((c %b) a) / b
11. int a = 100; char b; float c = 3.5; int d;
a. compute d = sizeof(a);
b. compute d = sizeof(b);
c. compute d = sizeof(c)
12. Sort the following binary operators in order of high to low precedence: +, -, *, /, %, =.
13. What is printed by the following code snippet? int x1 = 2, y1, x2 = 2, y2; y1 = ++x1; y2 = x2++;
cout << x1 << " " << x2 << ' '; cout << y1 << " " << y2 << ' ';
--x2; y1 = x2++; x1++; y2 = x1--;
cout << x1 << " " << x2 << ' '; cout << y1 << " " << y2 << ' ';
14. What is the value of variables a, b, and c in the program below after the statement 1, 2, and 3. Please fill-up the values of a, b, c in the table given below after each statement (1, 2 and 3) is executed.
int a = 5; int b = 6;
int c;
a = (b++) + 3; // Statement 1
c = 2 * a + (++b); // Statement 2
b = 2 * (++c) - (a++);// Statement 3
15. Consider the following section of C++ code:
#include stdafx.h #include
int main() {
int m = 3, n = 2, x , y;//Variable declarations and initializations x = m + 5; m--;
y = (m + 4)/3;
n = (n--) + 2;
m = m + n/2;
m++;
x = (--x) * 2 - 3;
y = y * 2;
n = n + y * 3;
cout << "m = " << m << endl; // Statement -1 for output printing
cout << "n = " << n << endl; // Statement -2 for output printing
cout << "x = " << x << endl; // Statement -3 for output printing
cout << "y = " << y << endl; // Statement -4 for output printing return 0;
}
What will be the value of variables m, n, x and y as printed in the statement -1, statement -2, statement -3 and statement -4?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started