Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
Question
Book Icon
Chapter 9, Problem 1P
Program Plan Intro

Program Plan:

  • Include required header files.
  • Declaration of function prototype.
  • Definition for function “main()”.
    • Declare and initialize the variable “var”.
    • Print the value before calling function
    • Call the function “addOne()”.
    • Print the value after calling function.
    • Return the value “0”.
  • Definition of function “addOne()”.
    • Increment the pointer variable.

Expert Solution & Answer
Check Mark
Program Description Answer

The given program is to add one to the integer referenced by “ptrNum” by using reference parameter syntax.

Explanation of Solution

//Include required header files

#include<iostream>

using namespace std;

//Declaration of function header

void addOne(int *ptrNum);

//Definition of function main()

int main()

{

    //Declare and initialize the variable "var".

    int var = 10;

    //Print the value before calling function

  cout << "Value before calling function = " << var << '\n';

    //Call the function

    addOne(&var);

    //Print the value after calling function

  cout << "Value after calling function = " << var << '\n';

    //Return the value "0"

    return 0;

}

//Definition of function "addOne()"

void addOne(int *ptrNum)

{

    //Increment the pointer variable

    *ptrNum = *ptrNum + 1;

}

Sample Output

Output:

Value before calling function = 5

Value after calling function = 6

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Problem Statement You are working as a Devops Administrator. Y ou’ve been t asked to deploy a multi - tier application on Kubernetes Cluster. The application is a NodeJS application available on Docker Hub with the following name: d evopsedu/emp loyee This Node JS application works with a mongo database. MongoDB image is available on D ockerHub with the following name: m ongo You are required to deploy this application on Kubernetes: • NodeJS is available on port 8888 in the container and will be reaching out to por t 27017 for mongo database connection • MongoDB will be accepting connections on port 27017 You must deploy this application using the CL I . Once your application is up and running, ensure you can add an employee from the NodeJS application and verify by going to Get Employee page and retrieving your input. Hint: Name the Mongo DB Service and deployment, specifically as “mongo”.
I need help in server client project. It is around 1200 lines of code in both . I want to meet with the expert online because it is complicated. I want the server send a menu to the client and the client enters his choice and keep on this until the client chooses to exit . the problem is not in the connection itself as far as I know.I tried while loops but did not work. please help its emergent
I need help in my server client in C language
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr