C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
Expert Solution & Answer
Book Icon
Chapter 12, Problem 17SA

Explanation of Solution

The program has been explained in the in-lined comments:

#include <iostream> 

using namespace std; 

int main()  

{  

    //delcare a list and initialize it

    //with an array of 6 elements 

    int numList[6] = {25, 37, 62, 78, 92, 13};

    //create a pointer to the list -

    //the base address of the list is assigned

    //to the pointer

    int *listPtr = numList;

    //a new pointer is declared and is assigned

    //an address 2 int positions incremented i.e

    //it points to the 3rd position in the array

    //or numlist[2] which is the value 62

    int *temp = listPtr + 2;

    //declare an int variable

    int num;

    //assign value of the memory address pointed to

    //by listPtr with the arithmetic expression on the

    //RHS of the assignment operator

    //RHS = *(listPtr + 1) - *listPtr = 

    //numList[1] - numList[0] = 37-25 = 12

    //since listPtr is numList[0] so now the array elements

    //are {12, 37, 62, 78, 92, 13}

    *listPtr = *(listPtr + 1) - *listPtr;

    //listPtr is incremented and now points to numList[1]

    // i.e. 37

    listPtr++;

    //num is assigned the value pointed to by temp which is

    //numList[2] i.e. 62

    num = *temp;

    //temp is incrementedand now points to numList[3] 

    //i...

Blurred answer
Students have asked these similar questions
#include <stdio.h>#include <stdlib.h>#include <time.h> struct treeNode {  struct treeNode *leftPtr;  int data;  struct treeNode *rightPtr;}; typedef struct treeNode TreeNode;typedef TreeNode *TreeNodePtr; void insertNode(TreeNodePtr *treePtr, int value);void inOrder(TreeNodePtr treePtr);void preOrder(TreeNodePtr treePtr);void postOrder(TreeNodePtr treePtr); int main(void) {  TreeNodePtr rootPtr = NULL;   srand(time(NULL));  puts("The numbers being placed in the tree are:");   for (unsigned int i = 1; i <= 10; ++i) {    int item = rand() % 15;    printf("%3d", item);    insertNode(&rootPtr, item);  }   puts("\n\nThe preOrder traversal is: ");  preOrder(rootPtr);   puts("\n\nThe inOrder traversal is: ");  inOrder(rootPtr);   puts("\n\nThe postOrder traversal is: ");  postOrder(rootPtr);} void insertNode(TreeNodePtr *treePtr, int value) {  if (*treePtr == NULL) {    *treePtr = malloc(sizeof(TreeNode));     if (*treePtr != NULL) {      (*treePtr)->data = value;…
C++ Programing Create an application to keep track of a list of students and their grades in a data structures course using a linked list. You should use the C++ STL library. You need to create a class called student that contains 2 data members: name and grade and then create a linked list of objects of this class. The application should allow the user to add a student, remove a student, update the grade for a student, and search for a student.
#include <stdio.h>#include <string.h>#define SIZE 6struct Student{char name[50];int id;float mark;};int Search1(char input[], struct Student data[]);int Search2(int input, struct Student data[]);int main() {char search_name[30];int search_id;int result1, result2;struct Student list[SIZE] = {{"Amylia", 544199, 75.4},{"Cheong", 143566, 92.3},{"Harry", 109774, 65.5},{"Krishnan", 334514, 86.7},{"Melissa", 257890, 55.4},{"Timothy",144656, 77.8}};printf("Enter Student Name: ");gets(search_name);result1 = Search1(search_name, list);//Answer for part (a)(ii) – Display the matching index of result1printf("Enter Student ID: ");scanf("%d",&search_id);result2 = Search2(search_id,list);//Answer for part (a)(iii)- Display the matching index of result2return 0;}//Answer for part (a)(i) – function definition for Search1//Answer for part (a)(iii) – function definition for Search2
Knowledge Booster
Background pattern image
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