Question

Assume that an int variable takes 4 bytes and a char variable takes 1 byte. Given...

Assume that an int variable takes 4 bytes and a char variable takes 1 byte. Given the following integer array:

int arr[5] = {12, 10, 13, 90, 1};

Explain the value of arr .  

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

Given,

=>Size of int = 4 bytes

=>Size of char = 1 byte

=> arr[5] = {12, 10, 13, 90, 1}

Explanation:

=> arr will represent the address of whole array[5].

=> arr will store the base address of array[5].

=> Let say base address of array[5] = 1000 then arr = 1000

=> If we want to calculate total length of array then it will be = 5*4 = 20

as the array is of integer type and contains 5 elements os total length is 20

I have explained each and every step with the help of statements attached to it.

Add a comment
Know the answer?
Add Answer to:
Assume that an int variable takes 4 bytes and a char variable takes 1 byte. Given...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Assume we have a size-of-24-bytes data memory as shown in Figure 1. How does int...

    1. Assume we have a size-of-24-bytes data memory as shown in Figure 1. How does int arr3) = {19088743, 2882400001, 169552957) get stored (assume arr[0] points to oth location)? Hints: Endianness. Report the following in your report. 23 22 1 0 Figure 1: Endianness (a) How much space (in byte) does one integer occupy considering a RISC-V architecture? (b) Draw the data mapping. 2. Continuing with 1, what is the value of x10 (assume x23 =0)? Id x8, 0(x23) Id...

  • #include <stdio.h> int main(int argc, char *argv[]) {      char a, *pc, c[9];      int i, *pk, k[9];      a='...

    #include <stdio.h> int main(int argc, char *argv[]) {      char a, *pc, c[9];      int i, *pk, k[9];      a='z';      pc=&(c[8]);      pk=&(k[0]);      for (i=0; i<9; i++)     {           *pc=a-(char)i;           pc--;           *pk=(int)a-i;           pk++;           }                     return 0; }//end of main Answer the below questions with the above code Write out the memory map for the above C code in the following table. For array variables, list the address range for the entire array. Assume the memory address starts from 100, that is, the address for a...

  • 3. Suppose that an array of size 5 is declared, of type integer (4 bytes). int...

    3. Suppose that an array of size 5 is declared, of type integer (4 bytes). int theArray[5]; Also, suppose that the computer assigns the memory address 3152 to the variable at index 0. Explain how the computer would access theArray[2], and what the memory address would be. Draw diagrams as necessary. Following are example question and answer: Suppose that an array of size 5 is declared, of type double (8 bytes). double theArray[5]; Also, suppose that the computer assigns the...

  • 72) Given a character pointer p_ch, and integer pointer p_int, and a float pointer, p_f, how...

    72) Given a character pointer p_ch, and integer pointer p_int, and a float pointer, p_f, how many bytes will be added/subtracted, respectively, in the following expressions: (assume that char is 1 byte, int 4 bytes, and float 4 bytes, respectively)                a)         p_ch - 4             b)         p_int + 20             c)        p_f + 13             d)         p_int - 1             e)         p_f – 1

  • Given an int variable grade, based on its value, assign a char variable letterGrade in the...

    Given an int variable grade, based on its value, assign a char variable letterGrade in the following way: 90 and above, ‘A’, 80 ~89, ‘B’, etc in java.

  • basic c++ 2. AC++ program contains the following C++ code (assume an int occupies 2 bytes...

    basic c++ 2. AC++ program contains the following C++ code (assume an int occupies 2 bytes each in memory): int x[ ] = { 10, 20, 30, 40, 50, 60, 70, 80); int *ptrx ptrx = x; Array x starts at memory location 2140. a. What is the value assigned to ptrx? b. What is the value of (x+2)? c. What is the value of *x? d. What is the value of (*x+2)? e. What is the value of *(x+2)?...

  • write a function called readAny having the following declaration: void readAny(fstream &iofile, char buffer[], int size, int start, int index); with five parameters, iofile is the fstream variable...

    write a function called readAny having the following declaration: void readAny(fstream &iofile, char buffer[], int size, int start, int index); with five parameters, iofile is the fstream variable for reading the file. Assume that the file has already been opened. buffer is the character array for returning the bytes that will be read in by the function. size specifies how many bytes to read in. start will have one of three constants 1, 2, or 3. 1 means from the...

  • Write a function named insertBeforeKey that takes the parameters as follows list as an char array,...

    Write a function named insertBeforeKey that takes the parameters as follows list as an char array, capacity for the capacity of the array, numItems has the number of items in the array, key is an element of the array before which newVal is to inserted. Assume key is always present in the array. and newVal has the new value to be inserted into the array. If the array is at capacity then the function should return -1, otherwise return 0...

  • Trying to do this in C++ Question 1: 1. Implement the function: int minInArray (int arr[],...

    Trying to do this in C++ Question 1: 1. Implement the function: int minInArray (int arr[], int arrSize) This function is given arr, an array of integers, and its logical size, arrSize. When called, t returns the minimum value in arr. Write a program that reads from the user a sequence of 20 integers (unnecessarily different from one another) into an array, and outputs the minimum value, and all the indices it appears in the array. 2. Your program should...

  • 2. Use hashing (solve_with_Hash(int[] array, int k)) Initialize a counter variable to O: Insert a...

    2. Use hashing (solve_with_Hash(int[] array, int k)) Initialize a counter variable to O: Insert all elements of array in a hashtable For every element in array: counter0 a. b. c. .Look for array[i] . Look for array [幻 + k in the hash map, if found then increment counter. -k in the hash map, if found then increment counter. Remove arrayli] from hash table. d. return counter For example: Input : array[] {1, 5, 3, 4, 2), k 3 Output:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT