Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 10.5, Problem 10.1CP
Program Plan Intro
Pointer:
- Pointer is a special type of variable to store the address of the memory location.
- If an asterisk “*” operator is present before the variable, then that variable is referred as pointer variable.
- It is also called as dereferencing or indirection operator.
- Pointer is just a type of variable that stores the address of other variables.
- Using pointers, we can access the address of a variable; the data stored in that variable can be retrieved.
Syntax of pointer variable declaration:
<variable-type> *<variable-name>;
Example for pointer variable declaration:
//definition of pointer variable
int *ptrvar;
Where,
- int is the variable type.
- * ptrvar is the pointer variable name.
Note:
- When the symbol “&” is placed prior the pointer variable, it will hold address of the pointer variable.
- When the symbol “*” is placed prior the pointer variable, it will hold the value of the pointer variable.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
The following statement is incorrect. Write the correct statement.
a = (x < 16) : 5 ? 11
Provide description on how to use the code.
Code is located below:
# initialize a flag variable with 0flag = 0 # loop will execute till flag is 0 in the sense loop will execute codewhile flag == 0 : #until amount is greater then costcost = float(input("Enter the cost: ")) # take input cost and convert to floating data typeamount = float(input("Enter the amount given(should be greater than cost): ")) # take inputif amount < cost :print("Amount should be greater than cost.") #print statement saying enter Amount thatelse:flag = 1 # when amount entered by user greater then cost flag is set to 1 and while loop will not execute
change = amount-cost #stored difference between amount and cost to change variableprint(f"The change to be given is ${change}") #print the value of change variable
twenty=0 #intializing all possible coin/ notes to 0ten=0five=0single=0quarter=0dime=0nickel=0penny=0
while change>=20 : #loop will execute until change become less then 20. this loop execute for…
Print "userNum1 is negative." if userNum1 is less than 0. End with newline. Assign userNum2 with 4 if userNum2 is greater than 9. Otherwise, print "userNum2 is less than or equal to 9.". End with newline.
C code
Chapter 10 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 10.5 - Prob. 10.1CPCh. 10.5 - Write a statement defining a variable dPtr. The...Ch. 10.5 - List three uses of the symbol in C++.Ch. 10.5 - What is the output of the following program?...Ch. 10.5 - Rewrite the following loop so it uses pointer...Ch. 10.5 - Prob. 10.6CPCh. 10.5 - Assume pint is a pointer variable. For each of the...Ch. 10.5 - For each of the following variable definitions,...Ch. 10.10 - Assuming array is an array of ints, which of the...Ch. 10.10 - Give an example of the proper way to call the...
Ch. 10.10 - Complete the following program skeleton. When...Ch. 10.10 - Look at the following array definition: const int...Ch. 10.10 - Assume ip is a pointer to an int. Write a...Ch. 10.10 - Assume ip is a pointer to an int. Write a...Ch. 10.10 - Prob. 10.15CPCh. 10.10 - Prob. 10.16CPCh. 10.10 - Prob. 10.17CPCh. 10.12 - Prob. 10.18CPCh. 10.12 - Assume the following structure declaration exists...Ch. 10.12 - Prob. 10.20CPCh. 10 - Each byte in memory is assigned a unique _____Ch. 10 - The _____ operator can be used to determine a...Ch. 10 - Prob. 3RQECh. 10 - The _____ operator can be used to work with the...Ch. 10 - Prob. 5RQECh. 10 - Creating variables while a program is running is...Ch. 10 - Prob. 7RQECh. 10 - If the new operator cannot allocate the amount of...Ch. 10 - Prob. 9RQECh. 10 - When a program is finished with a chunk of...Ch. 10 - You should only use the delete operator to...Ch. 10 - What does the indirection operator do?Ch. 10 - Look at the following code. int X = 7; int ptr =...Ch. 10 - Name two different uses for the C++ operator.Ch. 10 - Prob. 15RQECh. 10 - Prob. 16RQECh. 10 - Prob. 17RQECh. 10 - What is the purpose of the new operator?Ch. 10 - What happens when a program uses the new operator...Ch. 10 - Prob. 20RQECh. 10 - Prob. 21RQECh. 10 - Prob. 22RQECh. 10 - Prob. 23RQECh. 10 - Prob. 24RQECh. 10 - Prob. 25RQECh. 10 - Prob. 26RQECh. 10 - What happens when a unique_ptr that is managing an...Ch. 10 - What does the get ( ) method of the unique_ptr...Ch. 10 - Prob. 29RQECh. 10 - Prob. 30RQECh. 10 - Prob. 31RQECh. 10 - Prob. 32RQECh. 10 - Consider the function void change(int p) { P = 20;...Ch. 10 - Prob. 34RQECh. 10 - Write a function whose prototype is void...Ch. 10 - Write a function void switchEnds(int array, int...Ch. 10 - Given the variable initializations int a[5] = {0,...Ch. 10 - Each of the following declarations and program...Ch. 10 - Prob. 39RQECh. 10 - Test Scores #1 Write a program that dynamically...Ch. 10 - Test Scores #2 Modify the program of Programming...Ch. 10 - Indirect Sorting Through Pointers #1 Consider a...Ch. 10 - Indirect Sorting Through Pointers #2 Write a...Ch. 10 - Pie a la Mode In statistics the mode of a set of...Ch. 10 - Median Function In statistics the median of a set...Ch. 10 - Movie Statistics Write a program that can be used...Ch. 10 - Days in Current Month Write a program that can...Ch. 10 - Age Write a program that asks for the users name...Ch. 10 - Prob. 10PC
Knowledge Booster
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
- What is the output of the following code segment?inta=3,b=4;if(ab)Write(Y);WriteLine(Z); Y Z YZ nothingarrow_forwardWhen you try to access to a local variable outside the function an error is generatedSelect one:a. Falseb. Truearrow_forwardCan you declare a variable as int and later redeclare it as double?arrow_forward
- In Python Text-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. The selection variable must be sent as an argument into the choice() function. The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options. Add an if statement in the choice() function to make the correct selection.arrow_forwardThe Problem: You need to increment a variable in the fastest possible way.arrow_forwardQuestion: For the following code: for ( a = 1, b = 5, c = 3; a < 4; a++, b++ ) { c = a * b + c; } Indicate what values for the following variable will be when the code endsPlease check work for A = B = C =arrow_forward
- Define the term " pass by value " .arrow_forwardاسامه کلاس All Media 27/12/2021, 10:11 AM Q1: Write a C++ program to calculate the volume of a pyramid. Users are required to enter the dimensions of the pyramid, including its height, width, and length. If you enter negative values for length, width, and height, you will receive a display message indicating incorrect input. Afterward, after verifying the validity of these variables, the pyramid's volume is calculated and displayed. Recall that .arrow_forwardusing c#: Write an application named TestScores that continuously prompts a user for test scores until the user enters a sentinel value. A valid score ranges from 0 through 100. When the user enters a valid score, add it to a total; when the user enters an invalid score, display an error message. Before the program ends, display the number of scores entered their average.arrow_forward
- Why is it important that accumulator variables are initialised correctly?arrow_forwardThe following code returns a syntax error. if x > 5: print ("x is greater than 5.") print ("End of code") (A) True (B) Falsearrow_forwardYou will use sequential, selection and repetition programming statements. You will define one integer number: count count will store how many times valid weights and values have been entered. You will define a variety of doubles: weight, value, sum, sumw, avg value will store the input value weight will store the input weight for that value sum will store the running sum of values and weights sumw will store the running of the weights avg will store the weighted average of the 5 numbers and 5 weights input. The running sum will be calculated by this formula: sum = sum + value * weight For example, if the first value and weight pair entered is 4, 1 and second pair is 10, 3: sum = sum + value*weight = 0 + 4*1 sum = 4 + 10*3 = 34 sumw = 1 + 3 = 4 Values and sum are to be input and calculated within a repetition loop: while count < 5 Input value, weight sumw = sumw + weight sum = sum + value * weight count = count + 1 End while Avg is calculated by: avg =…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr