Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use C++ to write the following code. BCS 230 Lab 9 CRN 90110, 90111 Fall 2018 JLi Objective: To learn to use pointer variables to

Use C++ to write the following code.

image text in transcribed

BCS 230 Lab 9 CRN 90110, 90111 Fall 2018 JLi Objective: To learn to use pointer variables to manipulate data of different types. Tasks: Write a program that performs the following tasks 1) Declare an int variable num and assign an integer value 12 to it. Declare a pointer variable numptr that points to num. Write statements using the address-of operator&) and dereferencing operator() to output the address of num, the value of num the address of numptE the value of nummPt and the value pointed to by numPtr Observe the output 2) Declare an int array arrayA with five elements, and initialize the eleme l to 9. Declare an int aray arrays with five elements, and initialize the elements to the even integers from 2 to 10 nts to the odd integers from e pointer variable pt t that points to arrayi. Declare a pointer variable ptiB that points to arrayB 4) Use a for statement to output the address and the value of each element of arrayA using pEEA and array subscript notation. 5) Use a tor statement to output the address and the value of each element of ar rayB using ptrs and pointer offset notation. Observe the address output of arzayA and arrayB. 6) Write a function printarray to output the contents of an array. The function accepts an int pointer variable for an array and an int variable representing the size of the array 7) Write a function swapArray and call it to swap the contents of azray and arrayB. The swapArray function should have two int pointer variables and one int variable representing the size of array. Two arrays have the same size. The function prototype is: void swap (intl.pa, int xpl, nt size); 8) After swap two arrays. call printArray function to check the results. ip

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

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

10. Are you a. a leader? b. a follower? _______

Answered: 1 week ago