Question

When variables c1 and c2 are declared, are they located in memory continuously? Run the following...

When variables c1 and c2 are declared, are they located in memory continuously? Run the following program on your computer and print out the memory locations that are assigned to all the variables by your compiler. What are the memory locations of c1 and c2? Are the memory locations located next to each other?

char c1. c2;

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

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

No, they are not located continuously since there might be some other variables in between of those 2 variables..

Below is the cpp program to check.

#include <iostream>
using namespace std;
int main()
{
char c1,c2;
cout<<"Address of c1 is "<<(void*)(&c1)<<endl;
cout<<"Address of c2 is "<<(void*)(&c2)<<endl;

}

No, they are not next to each other since there might be some other elements in between.

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
When variables c1 and c2 are declared, are they located in memory continuously? Run 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
  • Prints out the size of (there’s a hint, by the way) variables with the following C...

    Prints out the size of (there’s a hint, by the way) variables with the following C data types – int, long, unsigned, long long, char, float and double. This is how many bytes of memory a variable of that type occupies on this machine, using your chosen compiler. (Xcode) Answer the following question: Does adding the static keyword to the declaration of these variables in your program change their size? Answer the following question: What is the largest number and...

  • Assignment • No variables declared after you start writing code, must be declared at the top....

    Assignment • No variables declared after you start writing code, must be declared at the top. • Reuse all the variables from the first half in the second half, do not make up new variable names. • You code must be properly formatted. • You must use the code provided and variables names provided and not add any more variables to your code. • No for(int I = 0; … no declaring variables except at top of code. • You...

  • Run the C program below and complete the table showing all the variables. Add printf function...

    Run the C program below and complete the table showing all the variables. Add printf function calls to obtain the addresses and values of all 13 variables. (Count the array (ca) as 3 variable/values and also include argc and argv in the table). The table must show the Address, Name, Datatype, Scope, and Value of each variable on the stack. (Hint: use the sizeof function to double check your addresses.) Explain how different the actual memory allocations are from what...

  • What does the final keyword mean when applied to variables? (Check all that apply.) Group of...

    What does the final keyword mean when applied to variables? (Check all that apply.) Group of answer choices All objects of the class share the variable Memory is allocated when the program begins Other classes have access to that variable The variable may be assigned only one time

  • Design a personType class with the following attributes (variables), and behaviors (methods/functions). Private Variables string fName;...

    Design a personType class with the following attributes (variables), and behaviors (methods/functions). Private Variables string fName; string lName; string address: double height (inches) string DOB char: gender Public functions setters for all of your data members (variables) getters for all of your data members print. This function will print "All of the persons' information". equals which takes another personType object as a parameter and compares all its members. Returns true is identical. Create a driver program that creates 5 different...

  • What is the final value of x in memory after the code below is run? 1...

    What is the final value of x in memory after the code below is run? 1 int x; 2 for (x=0; x<5; x++){ 3 4} Answer: Answer What is the result of the following bitwise operation in decimal? ((~6)&36)|(6)&(~36)), where ~, |, and & are the bitwise NOT, OR, and AND respectively. Answer: Answer Complete the attempt to allocate a 5-element array of pointers to doubles and initialise the associated double value to 0.0. double* a[10]; for (int j =...

  • Write a program using C/C++ to demonstrate the memory leak problem. Execute the program until it cannot proceed anymore. You may have to allocate big chunks of memory iteratively to reach to this poin...

    Write a program using C/C++ to demonstrate the memory leak problem. Execute the program until it cannot proceed anymore. You may have to allocate big chunks of memory iteratively to reach to this point quickly. This is even more so if you are running the program on a 64-bit operating system. Based on your observation and your understanding of the principles of a paging memory management system, answer the following questions: A. How much memory has the program used when...

  • Given the following code, determine the amount of memory required to store all of the variables...

    Given the following code, determine the amount of memory required to store all of the variables after the program has been executed (Hint: sum the variables) show your work. Then, tabulate your results in the form of the table below (a separate table ffor each part) then add to your report. Variable datatype    Memory for datatype (bits) # of elements Memory (bits) a logical 8 1 8*1 = 8 . . . . . . . . . ....

  • C Language Program. PLEASE USE DYNAMIC MEMORY AND FOLLOW DIRECTIONS GIVEN. USE FUNCTIONS GIVEN ALSO. Thank...

    C Language Program. PLEASE USE DYNAMIC MEMORY AND FOLLOW DIRECTIONS GIVEN. USE FUNCTIONS GIVEN ALSO. Thank you. NO FFLUSH. Problem 5 (40 points)-Write a program Submit orders.c (Note: you wil be dynamically allocating memory for this problem. The second argument on the command line will let you know how much memory you will be allocating. O points if you do not dynamically allocate) Chef Bartolomeo owns a very busy Italian restaurant. He has recently started accepting orders online and every...

  • 8. Given the following code part, when methodA) is running, list ALL variables that are on...

    8. Given the following code part, when methodA) is running, list ALL variables that are on the current program Stack? (assume that the compiler only allocates memory space when it sees a variable declaration) (8 pts) static int 10 void methodA) inta -123 return a1; void methodB(int b) t b b/12 3 static int c 2 c methodAl) int d[5]-(1,2, 3,4, 5 2-4G int main0 inta1, a2; methodB(15 return 0

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