Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ 1.) Some pointer arithmetic is allowed. Which of the following arithmetic operators are allowed? a.) pointer + integer b.) pointer - pointer c.) pointer

C++

1.) Some pointer arithmetic is allowed. Which of the following arithmetic operators are allowed?

a.) pointer + integer

b.) pointer - pointer

c.) pointer - integer

d.) integer + pointer

e.) integer * pointer

2.) Given the definitions,

int *p1, *p2;

p1 = new int;

p2 = new int;

What is the difference between the following two assignments.

a) p1 = p2;

b) *p1 = *p2

3. Given the declarations below, write a code fragment that allocates a nameless variable for pointer p1 to point to.

int *p1, *p2;

4. Give three uses for the * operator. Name and describe each use.

5. Your program creates a dynamically allocated array as follows:

int *entry;

entry = new int[10];

so that the pointer variable entry is pointing to the dynamically allocated array. Write code to fill this array with 10 numbers typed in at the keyboard.

6. Write the function with the following prototype to check if an integer is a prime number.

isPrime(int *);

7. What does the following function implement? How to call the gcd function in main function? If 8 and 12 are passed to a and b respectively, what is the content of the returned pointer?

int *gcd(int a, int b)

{

int *p;

int c;

p = &b;

while (a != 0) {

c = a;

a = b%a;

b = c;

}

return p;

}

8. Discuss the advantages of using multiple files in a C++ program.

9. How many main steps are there in C++ compilation? Describe their main tasks respectively.

10. What are the three basic preprocessor directives in header files?

Will leave thumbs up and positive comment for a complete response thank you!

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

=+4 What are non-union workers representations?

Answered: 1 week ago