Answer:
The program displays 5 4 3 2 1 and then raises an Array Index Out Of Bounds Exception.
Explanation:
A sample of code output is attached.
The code snippet contain xMethod that takes an array and array length as argument.
In the given snippet, the array {1, 2, 3, 4, 5} and length (5) is passed as argument to the method.
First the method display the element of the array in reverse order
System.out.print(" " + x[length - 1]);
and then the method call itself again. This displays
5 from x[4]
4 from x[3]
3 from x[2]
2 from x[1]
1 from x[0]
but after displaying 1, when it tries to call the method again, an array index out of bound exception is thrown because it will try accessing an element from the array when it is already exhausted.
Answer:
You can try emailing tech support and describing your issue. In order to get the best help as quickly as possible, try providing screenshots of what happens when you sign in or describe everything you see on the screen when the problem occurs, and quote error messages directly when possible.
This gap between user-designer communications <span>can cause a good project to go bad i</span>f the user is not able to process what is required to be fixed in order for the project to run smoothly. The user may have one way of fixing something while the designer has another. In this case, the designer understands how the project fully works while the user does not and this may end up compromising the whole project.
The law that “designers are not users” and “users are not designers” should always be followed.
Solution :
#include
#include
#include
//Converts to binary string.
* hexadecimalBinary(char* hexdec)
{
long = 0;
char *string = (sizeof(char) * 9);
while (hexdec[i]) {
//Simply assign binary string for each hex char.
switch (hexdec[i]) {
strcat(string, "0000");
break;
strcat(string, "0001");
break;
strcat(string, "0010");
break;
strcat(string, "0011");
break;
strcat(string, "0100");
break;
strcat(string, "0101");
break;
strcat(string, "0110");
break;
strcat(string, "0111");
break;
strcat(string, "1000");
break;
strcat(string, "1001");
break;
case 'A':
case 'a':
strcat(string, "1010");
break;
case 'B':
case 'b':
strcat(string, "1011");
break;
case 'C':
case 'c':
strcat(string, "1100");
break;
case 'D':
case 'd':
strcat(string, "1101");
break;
case 'E':
case 'e':
strcat(string, "1110");
break;
case 'F':
case 'f':
strcat(string, "1111");
break;
default:
printf("\nInvalid hexadecimal digit %c",
hexdec[i]);
string="-1" ;
}
i++;
}
return string;
}
int main()
{ //Take 2 strings
char *str1 =hexadecimalToBinary("FA") ;
char *str2 =hexadecimalToBinary("12") ;
//Input 2 numbers p and n.
int p,n;
scanf("%d",&p);
scanf("%d",&n);
//keep j as length of str2
int j=strlen(str2),i;
//Now replace n digits after p of str1
for(i=0;i<n;i++){
str1[p+i]=str2[j-1-i];
}
//Now, i have used c library strtol
long ans = strtol(str1, NULL, 2);
//print result.
printf("%lx",ans);
return 0;
}