subject

Q6 common mistakes in c

5 points

each of the following code samples below is making a common mistake in c. from the options, select the error type that best categorizes the mistake.

you can assume all the code has the necessary #include macros. also you should assume that the system is 32-bit.

1) #define password "correct horse battery staple"
char *check_permissions (char *user_guess) {
if (user_guess = password) {
return "access granted";
}
return "access denied";
}
probable segfault

double free

incorrect use of free

logic error

memory leak

no error

2) #define password "correct horse battery staple"
char *check_permissions (char *user_guess) {
if (user_guess == password) {
return "access granted";
}
return "access denied";
}
probable segfault

double free

incorrect use of free

logic error

memory leak

no error

3) int main () {
char *x = malloc(0x * sizeof(char));
x[0] = '! ';
}
probable segfault

double free

incorrect use of free

logic error

memory leak

no error

4) int foo () {
int *x = malloc(20);
x[0] = x[1] = 1;
x[2] = x[0] + x[1];
x[3] = 99;
return x[3];
}
probable segfault

double free

incorrect use of free

logic error

memory leak

no error

5) int main () {
char *x = "patrick";
printf("%s", x);
free(x); // tidy up
}
probable segfault

double free

incorrect use of free

logic error

memory leak

no error

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
3. (6 pts) internally in the computer, with few exceptions, all numerical computation is done using binary numbers. output, however, often uses ascii, which is formed by appending 011 to the left of a bcd code. thus, an algorithm that directly converts a binary integer to a bcd integer is very useful. here is one such algorithm 1) draw lines to the left of the binary number to bound the expected bcd decades. (each decade is a group of 4 bits.) move the binary number one bit to the left. add 0011 to each bcd decade containing a binary value> 0100 repeat steps 2-3 until the last bit in the binary number has been moved into the least significant decade position. (note that when the last bit has been shifted into bcd decade, step 3 is not repeated.) read the bcd result. 2) 3) 4) 5) a) execute the algorithm for the binary number 1101101 b) execute the algorithm for the binary number 01110101110 4. (4 pts) represent the decimal number 3568 in bcd; excess-3 code; ascil; and hex.
Answers: 1
question
Computers and Technology, 22.06.2019 11:30
Write a function so that the main program below can be replaced by the simpler code that calls function original main program: miles_per_hour = float( minutes_traveled = float( hours_traveled = minutes_traveled / 60.0 miles_traveled = hours_traveled * miles_per_hour print('miles: %f' % miles_traveled) sample output with inputs: 70.0 100.0 miles: 116.666667
Answers: 3
question
Computers and Technology, 23.06.2019 10:00
Hey i just logged on and one of the moderators deleted a bunch of my answers to questions, even though the answers were right and the people it doesn't make sense but if anyone wants to talk about anything just message me lol (this is super random lol)
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Jace needs to answer a question on square roots to win a quiz. how can he use a spreadsheet to find the square root of 786? a. use the functions round and count b. create a table and chart c. use the function sqrt d. use the function now
Answers: 3
You know the right answer?
Q6 common mistakes in c

5 points

each of the following code samples below is...
Questions
question
Arts, 14.05.2021 19:40
question
Mathematics, 14.05.2021 19:40
question
Computers and Technology, 14.05.2021 19:40
question
Mathematics, 14.05.2021 19:40
question
Mathematics, 14.05.2021 19:40
question
Mathematics, 14.05.2021 19:40
Questions on the website: 13722362