iptr is the address of array a So, iptr is 200 iptr + 1 = 200 + 1 * sizeof(int) = 200 + 1*4 = 200 + 4 = 204 So, output of the code is 204

204

Consider the following code. Assume that the array begins at memory address Ox200. What is printed...
C PROGRAM The following is code prints the current activation record number, the memory address of the current array, followed by the estimated size of the current activation record as a distance between the current array address and the array address from the previous activation record. I need it to run until a segmentation fault occurs and also it must print the estimated size of the runtime stack as a product of the size of current activation record and the...
QUESTION 1 In order to print the members of structures in the array, what will be the contents of blanks in the printf statement of the code snippet given below? #include <stdio.h> struct virus { char signature[25]; char status[20]; } v[2] = { "Yankee Doodle", "Deadly", "Dark Avenger", "Killer" } ; void main( ) { for (int i = 0; i < 2; i++) printf( "\n%s %s", _______________ , _____________ ); } A. signature, status B. v.signature,...
In the following code, what is the first line that introduces a memory leak into the program? (Type the line number into the box below) 1: #include <stdio.h> 2: #include <stdlib.h> 3: #include <string.h> 4: int main() { 5: char *word1 = NULL; 6: word1 = malloc(sizeof(char) * 11); 7: word1 = "bramble"; 8: char *word2 = NULL: 9: word2 = malloc(sizeof(char) * 11); 10: word2 = word1; 11: return 0; 12: }
QUESTION 10 What will be the output of following code snippet? char *str; str = "%s"; printf(str, "S"); A. S B. Garbage Value C. Compile-time Error D. Run-time Error 4 points QUESTION 11 What will be the output of the following statements assuming that the array begins at the memory address location 7002 and size of an integer is 4 bytes? int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; printf("%d,...
QUESTION 9 What will be the output of following code snippet? int a[3] = {1, 2, 3}; int *p = a; int **r = &p; printf("%p %p", *r, a); A. Different memory addresses printed B. 1 2 C. Same memory address printed twice D. 1 1 2 points QUESTION 10 What will be the output of following code snippet? int arr[4] = {1, 2, 3, 4}; int *p; p = arr + 3; *p = 5; printf("%d\n", arr[3]); A....
In this exercise we “reverse-engineer” some code to try to
determine how the heap in a C program is managed. Consider the
following C program (compiled as an executable called memory):
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
int chunk_sizes[4];
if ((argc != 2) ||
(sscanf(argv[1], "%d,%d,%d,%d", &chunk_sizes[0], &chunk_sizes[1], &chunk_sizes[2], &chunk_sizes[3]) != 4) ||
(chunk_sizes[0] < 0) || (chunk_sizes[1] < 0) || (chunk_sizes[2] < 0) || (chunk_sizes[3] < 0) ) {
fprintf(stderr,"Usage: %s a,b,c,d\n", argv[0]);
fprintf(stderr," where...
Assume the following about a computer with a cache: .. The memory is byte addressable. • Memory accesses are to 1-byte words (not to 4-byte words). .. Addresses are 8 bits wide. .. The cache is 2-way associative cache (E=2), with a 2-byte block size (B=2) and 4 sets (5=4). • The cache contents are as shown below (V="Valid"): Set #Way #0 Way #1 V=1;Tag=0x12; Data = v=1;Tag=0x10; Data = Ox39 0x00 0x26 Ox63 V=1;Tag=0x09; Data = v=1;Tag=0x11; Data =...
Q.25. Given the following program, you are asked to discuss memory leaks caused in its execution. Determine which memory locations get uncontrolled. (2 points) 4 6 7 8 9 10 11 12 B 13 14 15 16 17 18 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 5 void main() { char *aString = "Memory leaks?"; char **strList; int i, n = 5; strlist = (char**)malloc(n*sizeof(char*)); for (i=0; i<n; i++) { printf("\nstring %d ", i+1); strList[i] = (char*)malloc(50*sizeof (char));...
Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You can initialize the variables to any legal value of your choosing. Next, declare and initialize a pointer variable to each of the variables Using printf), output the following: The address of each of the first three variables. Use the "Ox%x" format specifier to print the addresses in hexadecimal notation The value of each variable. They should equal the value you gave...
Memory Consider a process running the following program #include estdlib.h> #include #define const char* int int <stdio.h> TO PRINT toPrintCPtr "Good luck!" TO PRINT; main for (i -0; i < sizeof (TO PRINT)-1; i++) printf("%c %c\n", toPrintCPt r [1], toupper(toPrintCPt r [i])); return(EXIT SUCCESS); Please tell where the following objects are stored in memory. Your choices are a. ROM BIOS b. kernal Memory (the OS) c. shared library memory (the glibc library) d. .text segment e. .rodata segment f. .data...