Question
A C function attempts to copy a substring.
#include #include #include char* copy_substring(const char* source, int start_index, int length) {   char* dest = (char*)malloc(length + 1);   if (dest == NULL) return NULL;   strncpy(dest, source + start_index, length);   dest[length] = '\0'; // Null-terminate   return dest; } int main() {   const char* original = "Programming"; // Length 11   char* sub = copy_substring(original, 5, 10); // start_index=5, length=10   if (sub) {     printf("Substring: %s ", sub);     free(sub);   }   return 0; } What is the most likely issue with copy_substring when called as in main?Solution
Correct Answer: B (source + start_index points to "amming". length is 10. strncpy will attempt to copy 10 characters starting from 'm'. However, "amming" only has 6 characters. strncpy will read 4 characters from "amming" and then 6 more characters from memory *after* "Programming", potentially causing a read out of bounds.)
I. 24x² - 58x + 23 = 0
II. 20y² + 24y – 65 = 0
I. 6x2 + 23x + 10 = 0
II. 2y2 - 3y - 5 = 0
I. p2 – 2p – 15 = 0
II. q2 + 4q – 12 = 0
Equation 1: x² + 16x + 63 = 0
Equation 2: y² + 10y + 21 = 0
Solve: x² − 7x + 12 = 0
I. 15y2 + 4y – 4 = 0
II. 15x2 + x – 6 = 0
I. x² + 4x + 4 = 0
II. y² - 8y + 16 = 0
I. 18p²- 21p + 6 = 0   Â
II. 16q² - 24q +9 = 0
I. 5x² - 24 x + 28 = 0  Â
II. 4y² - 8 y - 12= 0  Â
If x + 1/x = 3, find x² + 1/x².