Answer : True
Explanation: Vectors can hold, data of the same type and can automatically expand accordingly and change it’s size. The date stored in vectors should be linear.
- The syntax for vector is vector<int>v;
- Mostly this is used in C++ as an alternative to arrays
- If you want to use vector in your program then define it in the header first i.e.
#include <vector>
- Push back is a function, that is used to insert an element into the vector
- Pop back removes the element from the vector
There are two ways to convert from hexadecimal to denary gcse method. They are:
- Conversion from hex to denary via binary.
- The use of base 16 place-value columns.
<h3>How is the conversion done?</h3>
In Conversion from hex to denary via binary:
One has to Separate the hex digits to be able to know or find its equivalent in binary, and then the person will then put them back together.
Example - Find out the denary value of hex value 2D.
It will be:
2 = 0010
D = 1101
Put them them together and then you will have:
00101101
Which is known to be:
0 *128 + 0 * 64 + 1 *32 + 0 * 16 + 1 *8 + 1 *4 + 0 *2 + 1 *1
= 45 in denary form.
Learn more about hexadecimal from
brainly.com/question/11109762
#SPJ1
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;
}
Answer:
B: Hacker
Explanation:
literally anything else aren't even real things besides hacker.