
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
![b.
S
d.
struct {
char c;
short w;
int t;
long *foo;
} silly;
struct {
int i;
int j;
unsigned long foo;
long bar;
} record;
struct {
short qscores [4];
short halfs [2] ;
int overunder;
int spread;
} bline;
For this problem, give the address of the second element of each array (i.e., blineqscores[1].
and blinehalfs[1]), instead of the beginning of each array.](https://content.bartleby.com/qna-images/question/2b2b0246-74c5-427f-bbae-6a253749f017/0bf3d5c5-7c75-47b0-aff6-48cd60d62d3c/vz0tujp_thumbnail.png)
Transcribed Image Text:b.
S
d.
struct {
char c;
short w;
int t;
long *foo;
} silly;
struct {
int i;
int j;
unsigned long foo;
long bar;
} record;
struct {
short qscores [4];
short halfs [2] ;
int overunder;
int spread;
} bline;
For this problem, give the address of the second element of each array (i.e., blineqscores[1].
and blinehalfs[1]), instead of the beginning of each array.
![Problem 1. For each struct variable declared below, suppose the address of the first byte of the
variable is r. Give the bytes of each field of the variable, and the total number of bytes occupied
by the variable. You may assume that z is Don't forget about alignment restrictions (Text section
3.9.3)!
For example:
struct {
int eggs;
long chickens;
char name [10];
} henhouse;
Because of alignment, the compiler will leave (empty and useless) space (padding) between eggs
and chicken, because the latter must be 8-byte-aligned which the former is only 4 bytes long. So
we have the address of eggs is r; chickens is £ +8, and the character array name starts at x + 16.
The compiler also leaves a gap of six bytes at the end, so the end of the variable also aligned to an
8-byte boundary. So the size of the structure is 32 bytes (not 26).
a.
struct {
long q;
int 1;
short w;
char b1;
char b2;
} mystruct;](https://content.bartleby.com/qna-images/question/2b2b0246-74c5-427f-bbae-6a253749f017/0bf3d5c5-7c75-47b0-aff6-48cd60d62d3c/9m98qky_thumbnail.png)
Transcribed Image Text:Problem 1. For each struct variable declared below, suppose the address of the first byte of the
variable is r. Give the bytes of each field of the variable, and the total number of bytes occupied
by the variable. You may assume that z is Don't forget about alignment restrictions (Text section
3.9.3)!
For example:
struct {
int eggs;
long chickens;
char name [10];
} henhouse;
Because of alignment, the compiler will leave (empty and useless) space (padding) between eggs
and chicken, because the latter must be 8-byte-aligned which the former is only 4 bytes long. So
we have the address of eggs is r; chickens is £ +8, and the character array name starts at x + 16.
The compiler also leaves a gap of six bytes at the end, so the end of the variable also aligned to an
8-byte boundary. So the size of the structure is 32 bytes (not 26).
a.
struct {
long q;
int 1;
short w;
char b1;
char b2;
} mystruct;
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps

Knowledge Booster
Similar questions
- In Pseudocode #7 – List 4 main data types we used in this course and describe the data that is stored in each one. List examples of variable names that make sense for each data type. #8 – Debug this input validation function and fix it. There is a lot wrong with it! Function Integer getNumberGreaterThanX(msg, x) myInteger = getInteger(msg) While myInteger < x Display "The number must be < “, myInteger , “. Try again." Input x End While End Function Write the corrected function below: #9 – Write a validation function based on the provided variables and call statement below. The validation function should return an Integer value greater than zero or print an error message until an acceptable value is entered. Declare Integer positiveValue = 0 Declare String message = "Enter the year you were born (no negative numbers!)" positiveValue = getNumberGreaterThanZero(message) Write the function definition below:arrow_forwardProblem Description - JAVA PROGRAMMING Use a Two-dimensional (3x3) array to solve the following problem: Write an application that inputs nine numbers, each of which is between 1 and 10, inclusive. Display the array after the user inputs each value. Rotate/flip the array by changing places. Make the rows columns and vice versa. You have to move the elements to their new locations. Remember to validate the input and display an error message if the user inputs invalid data. Documentation and the screenshot(s) of the results. Example: 1 2 3 4 5 6 7 8 9 the result will be : 1 4 7 2 5 8 3 6 9arrow_forward5. Memory Layout Given the C struct definition below struct Simplestruct { int i; char c; double d; unsigned char a[11]; float f; }; struct Simplestruct ssp; Assume that int's are 4 bytes and have 4 byte alignment and that double has 8 byte alignment and float has 4 byte alignment. if calling printf("$x\n",ssp) yields CA028, what is the address of each field? You should express the answers in hexadecimal. &ssp->i = &ssp->c = &ssp->d = &ssp->a = &ssp->f =arrow_forward
- use c++ Programming language Write a program that creates a two dimensional array initialized with test data. Use any data type you wish . The program should have following functions: .getAverage: This function should accept a two dimensional array as its argument and return the average of each row (each student have their average) and each column (class test average) all the values in the array. .getRowTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the total of the values in the specified row. .getColumnTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The function should return the total of the values in the specified column. .getHighestInRow: This function should accept a two…arrow_forwardIn C++ please follow the instructions Write two code blocks -- one code block to declare a bag and its companion type-tracking array (both using the STL vector), and another code block to create and declare a Cat object and put it into the bag. Name the arrays and variables as you wish. Use any data type tracking and any designation for cats -- your choices. Assume that struct Cat is already defined and that all required libraries are properly included -- just write the two separate code blocks, separated by one or more blank lines.arrow_forwardGame of Hunt in C++ language Create the 'Game of Hunt'. The computer ‘hides’ the treasure at a random location in a 10x10 matrix. The user guesses the location by entering a row and column values. The game ends when the user locates the treasure or the treasure value is less than or equal to zero. Guesses in the wrong location will provide clues such as a compass direction or number of squares horizontally or vertically to the treasure. Using the random number generator, display one of the following in the board where the player made their guess: U# Treasure is up ‘#’ on the vertical axis (where # represents an integer number). D# Treasure is down ‘#’ on the vertical axis (where # represents an integer number) || Treasure is in this row, not up or down from the guess location. -> Treasure is to the right. <- Treasure is to the left. -- Treasure is in the same column, not left or right. +$ Adds $50 to treasure and no $50 turn loss. -$ Subtracts…arrow_forward
- In the code segment Double radius = 4.5; Const double* ptr = & radius;The ptr is constant, but the data pointed to by the pointer ptr is not constant options: True Falsearrow_forwardin c++ write a code to return the value of fake coin, the fake coin is The different element of the value in the array ،and need for way solution using 1) brute force approaches 2) divide and conquer 3) decrease and conquer 4) transform and conquer and write the time of each one and what the best time of them. in c++ write a code to return the value of fake coin, the fake coin is The different element of the value in the array and be less value (minimum) , need four way solution using 1) brute force approaches 2)divide and conquer 3)decrease and conquer 4) transform and conquer and write the time of each one and what the best time of them.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY