Subject : Data structure and algorithms Goal of the work : Consolidating knowledge on the theoretical foundations of abstract data structures, mastering the skills of calculating the declared amount of memory for structures using C++ syntax. Task : Given a data structure with three fields: an array of integers, a matrix of real numbers, and a string of characters. Calculate the total memory size (in bits, bytes, kilobytes, and megabytes) for record A, table B, and dynamic array variables C. *note: The data types are respectively equal to the memory size "short-2 byte", "int-4", "long-8", "float-4", "double-8", "long double -12", " char-1".

icon
Related questions
Question
Subject : Data structure and algorithms

Goal of the work : Consolidating knowledge on the theoretical foundations of abstract data structures, mastering the skills of calculating the declared amount of memory for structures using C++ syntax.

Task : Given a data structure with three fields: an array of integers, a matrix of real numbers, and a string of characters. Calculate the total memory size (in bits, bytes, kilobytes, and megabytes) for record A, table B, and dynamic array variables C.

*note: The data types are respectively equal to the memory size "short-2 byte", "int-4", "long-8", "float-4", "double-8", "long double -12", " char-1".

 

TASK-ASSIGNMENT
struct DATA
{
short P1[25];
double P2[7][7];
char P3[78];
} A, B[73],*C;
C=new DATA (21);
Transcribed Image Text:TASK-ASSIGNMENT struct DATA { short P1[25]; double P2[7][7]; char P3[78]; } A, B[73],*C; C=new DATA (21);
struct DATA
{
short P1[24]
long double P2[8][7];
char P3[51]
} A, B[50], C
C = new DATA (20)
Vp1 = 2b * 24 = 48b
Vp2 = 12b * 8 * 7 = 672 b
Vp3 = 1b * 51 = 51b
VaVp1 + Vp2 + Vp3 = 48 +672 +51 = 771 b
Vb =
771 5038550 b
Vc = 4 + 771 * 20 = 15424 b
Vgeneral = Va + Vb + Vc = 771 +38550 + 15424 = 54745 b
1 b = equal to 8 bits
54745*8 = 437960 bit
54745/ 1024 = 53,46 kb
53,46 / 1024 = 0,052 mb
EXAMPLE
Transcribed Image Text:struct DATA { short P1[24] long double P2[8][7]; char P3[51] } A, B[50], C C = new DATA (20) Vp1 = 2b * 24 = 48b Vp2 = 12b * 8 * 7 = 672 b Vp3 = 1b * 51 = 51b VaVp1 + Vp2 + Vp3 = 48 +672 +51 = 771 b Vb = 771 5038550 b Vc = 4 + 771 * 20 = 15424 b Vgeneral = Va + Vb + Vc = 771 +38550 + 15424 = 54745 b 1 b = equal to 8 bits 54745*8 = 437960 bit 54745/ 1024 = 53,46 kb 53,46 / 1024 = 0,052 mb EXAMPLE
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer