Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ Increment each integer in the array ' p ' of size ' n ' . / void increment _ ints ( int p [

/ Increment each integer in the array 'p' of size 'n'./ void increment_ints (int p [/*n/], int n)
{
assert(p!= NULL); /* Ensure that 'p' isn't a null pointer. */
assert (n >=0); / Ensure that 'n' is nonnegative. */
while (n)/ Loop over 'n' elements of 'p'.*/
{
*p++;
/ Increment *p.*/
p++, n--;
/* Increment p, decrement n.*/
}
}
Consider the function increment_ints(), defined above. Despite its significant inline commentary, it contains an error. Which one of the following correctly assesses it?
Pick ONE option
*p++ causes p to be incremented before the dereference is performed, because both operators have equal precedence and are right associative.
An array is a nonmodifiable lvalue, so p cannot be incremented directly. A navigation pointer should be used in conjunction with p.
*p++ causes p to be incremented before the dereference is performed, because the autoincrement operator has higher precedence than the indirection operator.
The condition of a while loop must be a Boolean expression. The condition should be n !=0.
An array cannot be initialized to a variable size. The subscript n should be removed from the definition of the parameter p.

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

Why can a hum usually be heard when a transformer is operating?

Answered: 1 week ago