Given the following source code 1 include 2 include 3 include 4, int verify_array(chars)
Posted: Sun May 15, 2022 9:59 am
Given the following source code 1 include <stdio.h> 2 include <stdlib.h> 3 include <string.h> 4, int verify_array(chars) 5 for(int 1-0; strlen(s): 1.) 6 if(!(s[1]-. || [1] - 'Il s)' (s[1] C'9' > '0')) { 8 return 0; 9 1 10 return 1: 12 13, char * mystery(char* anr, int size) { 14 charnew_n (char*) malloc(sizeof(char)*(size-6)); 15 char code[5] - "(212); 16 for (int i;i<5;1++) 17 18 new_nun[1]-code(1); 19 1 20 for (int 10; sizes +) 21 22 new_num(5+1]-arx; 23 } 24 25 size size 5: 26 return new_nu; 27 ) 28 29, int main(void)! 30 char number() -745-1234"; 31 char ret; 32 int size strlen(number): 33 ret mystery (number, size) 34 if(verify array(ret) 35 print(systery return: #s, s', ret, size): 36 return 0; 37] 1) What is the output of the program? (2) Does this program have any memory leak? If yes, where should free be placed? use line number in the figure to answer. A sample answer could be "free should be placed under line 23" The following diagram is the memory diagram of heap and stack when one of the functions in the above figure is about to return. Based on the following diagram, answering question (3)-7). You do not need to draw any lines. Singe aanaa Low address 20272 ution 3 Odraba wirow.vare BOD290 High address (3) What is unknown function 1? choosing from main, mystery and verify_array. (4) What is unknown function 2? choosing from main, mystery and verify_array. (5) What is the variable name of unknown_var 3? (6) What is the value of unknown_var 2? (7) What is the value of unknown var 1?