Question

Create a console application that perform the following: 1. a) Display the size of the following...

Create a console application that perform the following:

1. a) Display the size of the following primitive data type: char, short, int long, float, double

b) Display the size of a pointer.

2.

Display the following memory address for your program:

Beginning data segment

Start and End of the program segment. (hint: One of the functions must be an empty function

place at the end of the program file, that will be the address of the end of the program segment).

Start of the Heap address of the main program

Start of the Stock address of the main program

3. Define a function and call it using using a pointer (call back function).

4. Determine and display the start, end and size of the heap memory the operating system allocate to

your program.

5. Determine and display the start, end and size of the stack memory the operating system allocate to

your program. (hint: recursion. If you use the call back function for this, then you satisfy #3 as well).

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

AS PER CHEGG RULES I AM ABLE TO ANSWER FIRST ONE ONLY

ANSWER:

EXPLANATION AND CODE:

A)

#include<iostream>
using namespace std;

int main()
{
   cout << "Size of char: " << sizeof(char)
     << " byte" << endl;
   cout << "Size of int: " << sizeof(int)
     << " bytes" << endl;
   cout << "Size of short int: " << sizeof(short int)
     << " bytes" << endl;
   cout << "Size of long: " << sizeof(long int)
      << " bytes" << endl;
   cout << "Size of float: " << sizeof(float)
      << " bytes" <<endl;
   cout << "Size of double: " << sizeof(double)
      << " bytes" << endl;       
   return 0;
}

Output on a 64-bit compiler:

Output on a 32-bit compiler

(b)Size of pointer code:

#include<iostream>
using namespace std;
  
int main()
{
int a=5;
int *ptr=&a;
cout << "Size of pointer: " << sizeof(ptr)
<< " bytes" <<endl;
return 0;
}

Output on a 64-bit compiler:

Size of pointer: 8 bytes

Output on a 32-bit compiler:

Size of pointer: 4 bytes

RATE THUMBSUP PLEASE

Add a comment
Know the answer?
Add Answer to:
Create a console application that perform the following: 1. a) Display the size of the following...
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
  • Name: Homework #13 What are the two memory pools for programs running a modern operating system? ...

    code in C++ Name: Homework #13 What are the two memory pools for programs running a modern operating system? 1. Given the following program: 2. sincludeciostream> using nanespace std; void func1(int); int main() int a 5, b 10; func1(a): return 0; void func1(int a) int z(2]: int ys a. What is on the stack before the first function call (assume a memory starting address of ex1018)? b. What is on the stack after the function call is executed (before returning...

  • please answer all 5 questions, thanks. 1. What are the two memory pools for programs running...

    please answer all 5 questions, thanks. 1. What are the two memory pools for programs running a modern operating system? 2. Given the following program: #includec iostream» using namespace std; void func1(int); int main( int a 5, b 10; func1(a): return e; void func1 (int a) int z[2]; int y a. What is on the stack before the first function call (assume a memory starting address of 0x1018)? b. What is on the stack after the function call is executed...

  • CS 241 Program 03 Due: Thursday, October 18th Main topics: Arrays& Pointers Memory allocation ram Specification:...

    CS 241 Program 03 Due: Thursday, October 18th Main topics: Arrays& Pointers Memory allocation ram Specification: A stack is a container that can be defined in terms of an array where all adds are preformed at the end of the sequence of existing values, and all removes are also preformed at end of the sequence of existing values. An empty stack is one that has no existing values in the array at all. We use the notion of top of...

  • In this project you will create a console C++ program that will have the user to...

    In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and 365 days and store them in a dynamically allocated array, then display a report showing both the Celsius and Fahrenheit temperatures for each day entered. This program will require the use of pointers and dynamic memory allocation. Getting and Storing User Input: For this you will ask the user how many days’ worth of temperature...

  • Note: The question needs to be answered in "C Programming Languange ". And after the question fin...

    Note: The question needs to be answered in "C Programming Languange ". And after the question find 3 pages for needed informations. Spring CE4717 Language Processors Q1. Consider the following LEx program. return R1 return R2 return R3 return R4 return R5; return R6; IA-2a-z)[A-Za-z0-9]- -2 10-91+ 10-9a-EA-FI Ihi] [01] [01] 이삐 t Vtin) int main (void) int tcode; do f tcode -yylex()i printf ("token type td \"%s\"\n", tcode, yytext); ) while (tcode)i return 0; i. Explain the steps needed...

  • Write program in C. Please ask the user to determine how many numbers to enter, and...

    Write program in C. Please ask the user to determine how many numbers to enter, and then find and display the largest one with two digits. Please call the following two functions in your main functions. void input_numbers(float *data, int num); void find_largest(float *data, int num); Note: In this assignment, please save the entered numbers using pointer, pass the pointer as the arguments. Depending upon the number of elements, the required size is allocated which prevents the wastage of memory....

  • Need help about C PROGRAMMING,, pls use only C LANGUAGE.., yea so im doing this exercise...

    Need help about C PROGRAMMING,, pls use only C LANGUAGE.., yea so im doing this exercise as a practice for c programming, could someone do this as well so i could compare if my code makes makes sense and to see and help correct the errors im getting right now.. Any helpful help would be appreciated.. Pointers &Pointer arithmetic Memory allocation and freeing Main topics: Exercise This lab is designed to give you practice working with pointers and memory allocation...

  • Create a C# console application that performs the following: 1) Build a method which reads 3...

    Create a C# console application that performs the following: 1) Build a method which reads 3 integers from the console and returns them as an int array (type a number, then hit enter, 3 times). This needs to be its own method. 2) Call this method twice to store 2 local int array variables. 3) Once both arrays are built, write another method which accepts the two arrays and compares the contents to see if they match. If the method...

  • Create a C# console application that performs the following: 1) Build a method which reads 3...

    Create a C# console application that performs the following: 1) Build a method which reads 3 integers from the console and returns them as an int array (type a number, then hit enter, 3 times). This needs to be its own method. 2) Call this method twice to store 2 local int array variables. 3) Once both arrays are built, write another method which accepts the two arrays and compares the contents to see if they match. If the method...

  • Here's an assignment that'll give you some practice with pointers. All you have to do is...

    Here's an assignment that'll give you some practice with pointers. All you have to do is write a program that allows the user to populate an array of doubles (5 values) by calling the function InitArray. After the user has entered all the values, then call the function DispRevArray to display the array in reverse. Main will create and allocate space for an array of type double for 5 elements. Then you will create and allocate a pointer that will...

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