Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please i need help with this and the language is c++ ( use c++ to write) thank you 1. (3 points) Create a new file

image text in transcribed
image text in transcribed
image text in transcribed
please i need help with this and the language is c++ ( use c++ to write) thank you
1. (3 points) Create a new file called pointerBasics.cpp. Write a C++ program in this new file. In this new file, write code that will do the following: a. (1 point) Declare and assign values to variables i. Declare an integer variable called myint and assign the value 15 to it. ii. Declare a pointer variable called my Pointer using the dereference operator (*) and assign it to the memory location of myint using the address of operator (&) b. (1 point) Print to console i. Print the memory location of myint (remember the address-of operator!) and the value of my Pointer. ii. Print the value of myint and the value pointed to by my Pointer (remember the dereference operator!) c. (1 point) Change values and print to console i. Change the value of myint to 10. ii. Print the memory location of myint (remember the address of operator!) and the value of my Pointer. iii. Print the value of myint and the value pointed to by myPointer (remember the dereference operator!) 2. (15 points) Create a new file named array_ptrs.cpp and in this file, write a program that does the following: a. Defines an array of integers called my_ints with a pre-specified size of 4. b. Populates my_ints with input data provided by the user C. Defines an array of pointers called my_ptrs of the same size as my_ints and initializes the pointers in my_ptrs to point to corresponding elements of the array my_ints (refer to the "initial state" in the example shown below) d. Sort the array of pointers my_ptrs in a way such that the pointer at index 0 (i.e., the first element of my_ptrs) points to the smallest element in my_ints, the pointer at index 1 points to the next larger element in my_ints, etc. (refer to the "State after sorting my_ptrs" in the example shown below). e. Traverse the array my_ptrs and print the values being pointed to by each pointer in this array. Example: Initial state: State after sorting my_ptrs: my_ptrs my_ints 10 my ptrs mple: tial state: State after sorting my_ptrs: y ptrs my ints my_ptrs 10 my_ints 10 1 25 Expected output: 1 7 10 25

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial Databases 2nd Symposium Ssd 91 Zurich Switzerland August 1991 Proceedings Lncs 525

Authors: Oliver Gunther ,Hans-Jorg Schek

1st Edition

3540544143, 978-3540544142

More Books

Students also viewed these Databases questions

Question

How can the Internet be helpful in a job search? (Objective 2)

Answered: 1 week ago