What is the output of the following code segment?
public class Exception {
...
static int...
What is the output of the following code segment?
public class Exception {
...
static int divider(int x, int y) {
try {
return x/y;
} catch (ArrayIndexOutOfBoundsException a) {
System.out.print("A");
return 1;
}
}
static int computer(int x, int y) {
try {
return divider(x,y);
}
catch (NullPointerException b) {
System.out.print("B");
}
return 2;
}
public static void main(String args[]){
try {
int i = computer (100, 0);
}
catch (ArithmeticException c) {
System.out.print("C");
}
}
}
ABC
A...
What is output?
#include <stdio.h>
void CheckValue(int* pointVar1, int* pointVar2)
{
if (pointVar1 == NULL...
What is output?
#include <stdio.h>
void CheckValue(int* pointVar1, int* pointVar2)
{
if (pointVar1 == NULL && pointVar2 == NULL)
{
printf("Pointer is
null\n");
}
else if (*pointVar2 > *pointVar1) {
printf("%p\n",
*pointVar2);
}
else if (*pointVar1 > *pointVar2) {
printf("%p\n",
*pointVar1);
}
}
int main() {
int num1 = 5;
int num2 = 9;
CheckValue(&num1,
&num2);
return 0;
}
a.
0
b.
5
c.
9
d.
Pointer is null
e....
Translate C code into MIPS. Do not include an exit syscall
int proc1( int a, int...
Translate C code into MIPS. Do not include an exit syscall
int proc1( int a, int b ) {
if ( proc2( a, b ) >= 0 )
return 1;
else
return -1;
}
int proc2( int a, int b ) {
return (a*10) & (b*10);
}
int main() {
int a = 9;
int b = -10;
int c = a + b + proc1( a, b );
printf("%d\n", c );
return 0;
}
Below is C code and Python code for an algorithm.
C code:
void foo( int n,...
Below is C code and Python code for an algorithm.
C code:
void foo( int n, int A, int B, int C ) {
if( n==1 ) {
printf("%d to %d\n",A,B);
return;
}
foo( n-1, A, C, B );
printf("%d to %d\n",A,B);
foo( n-1, B, C, A );
Python code:
def foo(n , A, B, C):
if n==1:
print A, "to", B
return
foo(n-1, A, C, B)
print A, "to", B
foo(n-1, B, C, A)
Let Hn be the number...
1. Given the
following segment of code: (If there is nothing output, write
None.)
int x;...
1. Given the
following segment of code: (If there is nothing output, write
None.)
int x;
int y;
cin >> x;
cin >> y;
while (x > y)
{
x -= 3;
cout << x
<< " ";
}
cout << endl;
a. What are the output and final values of x and
y when the input is 10 for x and 0 for y? [2, 2, 2]
Output
x = ______________
...