1 Basics
1 Basics
3. Which combination of the integer variables x, y and z makes the variable a get the value 4 in
the following expression? (GATE-2008)
a = ( x> y ) ? (( x > z ) ? x : z) : (( y > z ) ? y : z )
a) x = 3, y = 4, z = 2 b) x = 6, y = 5, z = 3
c) x = 6, y = 3, z = 5 d) x = 5, y = 4, z = 5
8. The attributes of three arithmetic operators in some programming language are given below.
(GATE 2016)
Operator Precedence Associativity Arity
+ High Left Binary
- Medium Right Binary
* Low Left Binary
The value of the expression 2 - 5 + 1 - 7 * 3 in this language
is
10. The following function computes XY for positive integers X and Y.(GATE 2016)
intexp(int X, int Y)
{
int res = 1, a = X, b = Y;
while ( b != 0 )
{
if ( b%2 == 0)
{
a = a*a;
b = b/2;
}
else
{
res = res*a;
b = b-1;
}
}
return res;
}
Which one of the following conditions is TRUE before every iteration of the loop
A) XY = ab B) (res*a)Y = (res*X)b C) XY = res*ab D) XY = (res*a)b