Answer to Question #211801 in C++ for I need your HELP

Question #211801

Topic: Basics of C++ Programming Language "ARRAY IN C++"


Codes discussed will be posted here. Write your conclusion on the ARRAY discussion. 


Filename: BaseAddressOfAnArray.cpp

Code:

--->> https://drive.google.com/file/d/1K_qfp_9mNINFkkwpPzou9WniBmk-KsMK/view?usp=sharing


*Note need proper codes and conclusion on how it's done and about the results. And please give the proper solution and explanation.


Note: Place your conclusion on why did it turn out like that and give your reasons why the results turned like that, one paragraph will do for the explanation and conclusion.


Note: Please place the proper conclusion and explanations and results of the codes which were given.


1
Expert's answer
2021-07-03T04:48:59-0400

Cpp program:

#include <iostream>
using namespace std;
int main()
{
int myList[5] = {0, 2, 4, 6, 8}; //Line 1
int yourList[5]; //Line 2
cout << "Line 3: Base address of myList: "<< myList << endl; //Line 3
cout << "Line 4: Base address of yourList: "<< yourList << endl; //Line 4
if (myList == yourList) //Line 5
cout << "Line 6: The base addresses of "<< "myList and yourList \n"<< " are the same."<< endl; //Line 6
else if (myList < yourList) //Line 7
cout << "Line 8: The base address of "<< "myList is less than the \n"<<" base address of "<< "yourList." << endl; //Line 8
else //Line 9
cout << "Line 10: The base address of "<< "myList is greater than the \n"<< " base address of "<< " yourList." <<endl;
return 0;
}


Output:


Explanation:

In this program there is two variable out of which first one is of integer type array name is myList[5] which contains 5 elements and second one is the integer type array which does not have any elements initially that yourList[5].

In the program we are printing the memory base address of the above two array variable. For example the allocation of the first momory address for the varaible myList[5] is 0x61fe00 and for the variable yourList[5] is 0x61fde0. These memory addresses are representing the first momory addresses of the arrays.

Here in the both memory addresses first terms contains 0x which means it is in hexadecimal form. Now, program is checking that out of these two memory addresses, which one is greater, and program check and print the greater one.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS