EBK DATA STRUCTURES AND ALGORITHMS IN C
EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
bartleby

Concept explainers

Question
Book Icon
Chapter 1, Problem 3E

a)

Program Plan Intro

The content of array is been initialized with given values and “*p” is assigned to the beginning of the array, now after executing each instructions individually results are obtained given below.

Explanation of Solution

Explanantion:

In the above program , an integer array is been declared first. A pointer “p” points to array. The pointer “p” is been incremented to obtain second element of integer array. Finally,program displays contents of array and value of “p”

Therefore, the content of “intArray” will be

Explanation of Solution

b)

(*p)++;

The integer pointer “p” points to first elemenst of the array. So, “*(p)++” denotes that first element of array is been incremented first and then it is assigned to “*p”. Hence, first element of array increments as a result of this instruction.

This program shows execution of the construct and displays the result of the array and value of “p”.

Program:

//Select header files

#include <stdio.h>

#include<iostream>

using namespace std;

// Main function

int main(void)

{

  // Integer array with declaration

  int arr[] = {1,2,3};

Here, “p” denotes pointer to integer array...

Explanation of Solution

Explanantion:

In the above program an integer array is declared first. A pointer “p” points to array. The content pointed to by “p” is been incremented . Finally program displays contents of array and value of “p”.

Therefore, the content of “intArray” will be {

Explanation of Solution

c)

*p++; (*p)++;

The integer pointer “p” points to first element of array. So, *p++ denotes second element of array. Hence, second element of array increments and the incremented value is stored in “p”.

This program shows the execution of the construct and displays result of array and value of “p”.

Program:

//Select header files

#include <stdio.h>

#include<iostream>

using namespace std;

// Main function

int main(void)

{

  // Integer array with declaration

  int arr[] = {1,2,3};

...

Explanation of Solution

Explanantion:

In the above program an integer array is declared first. A pointer “p” points to array. The pointer is incremented, so that it now points to second element of array . Now, the contents pointed to by “p” is been incremented. Finally the program displays contents of array and value of “p”

Therefore, the content of “intArray” will be

Blurred answer
Students have asked these similar questions
C CodeApproved Libraries:<stdio.h><math.h><stdlib.h><time.h> (for srand(time(0)) only)
C CodeApproved Libraries: <stdio.h><math.h><stdlib.h><time.h> (for srand(time(0)) only)
Create a C++ Programming (see attached photo below for the problem and sample explanation)
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education