Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 8.7, Problem 8.13CP
Explanation of Solution
Output of the program:
Program:
//Header file
#include <iostream>
#include <iomanip>
using namespace std;
//Main function
int main()
{
//Declare and initialize the array
double balance[5] = {100.0, 250.0, 325.0 , 500.0,
1100.0};
//Declare the constant value
const double INT_RATE = 0.1;
//Set up the numeric output formatting
cout <<fixed<< showpoint << setprecision(2) ;
//Execute the for loop until the count is less than 5
for (int count = 0; count < 5; count++)
//Calculate the balance
cout << (balance[count] * INT_RATE ) &...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
-0
FAMAS oro ag
-0
1 void printVerticalGraph(int nUnits) {
2
4
9
10
11
12
13
14
15
16
17
456
BARHEIDEN
18
19
20
21
22
23
24
25
26
27
int nRev;
printf("%d\n", nUnits);
while (nUnits>0){
nRev = getReverse (nUnits);
// 1) Adjust nUnits
?? [Q1] ??
while (nRev>0){
nUnits *= 10;
// 2) Condition to print *
if(?? [Q2]??) {
printf("*");
}
// 3) Update for nUnits for * case
?? [Q3] ??
}else{
printf(" ");
// 4) Update for nUnits for
?? [Q4]??
}
// 5) Update to nRev
?? [Q5]??
printf("\n");
case
int func(int a, int b)
{
return (a
Match the C-function on the left to the Intel assemble function on the right.
W:
cmpl $4
movl %edi , %edi
jmp .L4(,%rdi,8)
%edi
.L3:
movl $17, %eax
ret
.15:
movl $3, %eax
int A ( int x , int y) {
int a ;
if ( x == 0 )
else i f ( x == 1 ) a = 3 ;
else i f ( x == 2 ) a = 2 0 ;
else i f ( x == 3 ) a = 2 ;
else i f ( x == 4 ) a = 1 ;
ret
.L6:
a = 17;
movl $20, %eax
ret
.L7:
movl $2, %eax
ret
else
a = 0;
.L8:
return a ;
movl $1, %eax
.L2:
ret
. section .rodata
. L4:
.quad .L3
.quad .L5
.quad .L6
.quad .L7
.quad .L8
X:
testl %edi, %edi
je
cmpl
je
cmpl
je
стр1
je
cmpl
.L16
$1, %edi
.L17
$2, %edi
.L18
$3, %edi
int B (int x, int y) {
int a;
switch (x) {
.L19
$4, %edi
%al
movzbl %al, %eax
case 0: a = 17; break;
sete
break;
case 1: a = 3;
case 2: a = 20; break;
case 3: a = 2; break;
case 4: a = 1;
a = 0;
}
return a;
ret
.L16:
break;
movl
$17, %eax
ret
.L17:
movl
$3, %eax
}
ret
.L18:
movl
$20, %eax
ret
.L19:
movl
ret
$2, %eax
Chapter 8 Solutions
Starting Out with C++: Early Objects (9th Edition)
Ch. 8.3 - Define the following arrays: A) empNum, a 100...Ch. 8.3 - Prob. 8.2CPCh. 8.3 - Prob. 8.3CPCh. 8.3 - Assume a program includes the following two...Ch. 8.3 - What is array bounds checking? Does C++ perform...Ch. 8.3 - What is the output of the following code? int...Ch. 8.3 - Complete the following program skeleton so it will...Ch. 8.7 - Define the following arrays: A) ages, a 10-element...Ch. 8.7 - Indicate if each of the following array...Ch. 8.7 - Prob. 8.10CP
Ch. 8.7 - Given the following array definition: int values...Ch. 8.7 - Prob. 8.12CPCh. 8.7 - Prob. 8.13CPCh. 8.7 - What is the output of the following code? const...Ch. 8.9 - Write a typedef statement that makes the name...Ch. 8.9 - Prob. 8.16CPCh. 8.9 - What is the output of the following program...Ch. 8.9 - The following program segments, when completed,...Ch. 8.11 - Prob. 8.19CPCh. 8.11 - Prob. 8.20CPCh. 8.11 - Prob. 8.21CPCh. 8.11 - Prob. 8.22CPCh. 8.11 - Prob. 8.23CPCh. 8.11 - Fill in the empty table below so it shows the...Ch. 8.11 - Write a function called displayArray7. The...Ch. 8.11 - Prob. 8.26CPCh. 8.12 - Prob. 8.27CPCh. 8.12 - Write definition statements for the following...Ch. 8.12 - Define gators to be an empty vector of ints and...Ch. 8.13 - True or false: The default constructor is the only...Ch. 8.13 - True or false: All elements in an array of objects...Ch. 8.13 - What will the following program display on the...Ch. 8.13 - Complete the following program so that it defines...Ch. 8.13 - Add two constructors to the Product structure...Ch. 8.13 - Prob. 8.35CPCh. 8.13 - Prob. 8.36CPCh. 8.13 - Prob. 8.37CPCh. 8.13 - Write the definition for an array of five Product...Ch. 8.13 - Write a structure declaration called Measurement...Ch. 8.13 - Write a structure declaration called Destination ,...Ch. 8.13 - Define an array of 20 Destination structures (see...Ch. 8 - The ________ indicates the number of elements, or...Ch. 8 - The size declarator must be a(n) _______ with a...Ch. 8 - Prob. 3RQECh. 8 - Prob. 4RQECh. 8 - The number inside the brackets of an array...Ch. 8 - C++ has no array ________ checking, which means...Ch. 8 - Prob. 7RQECh. 8 - If a numeric array is partially initialized, the...Ch. 8 - If the size declarator of an array definition is...Ch. 8 - Prob. 10RQECh. 8 - Prob. 11RQECh. 8 - Prob. 12RQECh. 8 - Arrays are never passed to functions by _______...Ch. 8 - To pass an array to a function, pass the ________...Ch. 8 - A(n) ________ array is like several arrays of the...Ch. 8 - Its best to think of a two -dimensional array as...Ch. 8 - Prob. 17RQECh. 8 - Prob. 18RQECh. 8 - When a two -dimensional array is passed to a...Ch. 8 - When you pass the name of an array as an argument...Ch. 8 - Look at the following array definition. int values...Ch. 8 - Given the following array definition: int values...Ch. 8 - Prob. 23RQECh. 8 - Assume that array1 and array2 are both 25-element...Ch. 8 - Prob. 25RQECh. 8 - How do you establish a parallel relationship...Ch. 8 - Look at the following array definition. double...Ch. 8 - Prob. 28RQECh. 8 - Prob. 29RQECh. 8 - Prob. 30RQECh. 8 - Prob. 31RQECh. 8 - The following code totals the values in each of...Ch. 8 - Prob. 33RQECh. 8 - Prob. 34RQECh. 8 - In a program you need to store the identification...Ch. 8 - Prob. 36RQECh. 8 - Prob. 37RQECh. 8 - Prob. 38RQECh. 8 - Each of the following functions contains errors....Ch. 8 - Soft Skills Diagrams are an important means of...Ch. 8 - Perfect Scores 1. Write a modular program that...Ch. 8 - Larger Than n Create a program with a function...Ch. 8 - Roman Numeral Converter Write a program that...Ch. 8 - Chips and Salsa Write a program that lets a maker...Ch. 8 - Monkey Business A local zoo wants to keep track of...Ch. 8 - Rain or Shine An amateur meteorologist wants to...Ch. 8 - Lottery Write a program that simulates a lottery....Ch. 8 - Rainfall Statistics Write a modular program that...Ch. 8 - Lo Shu Magic Square The Lo Shu Magic Square is a...Ch. 8 - Baseball Champions This challenge uses two files...Ch. 8 - Chips and Salsa Version 2 Revise Programming...Ch. 8 - Stats Class and Rainfall Statistics Create a Stats...Ch. 8 - Stats Class and Track Statistics Write a client...Ch. 8 - Prob. 14PCCh. 8 - Drivers License Exam The State Department of Motor...Ch. 8 - Array of Payro11 Objects Design a PayRoll class...Ch. 8 - Drink Machine Simulator Create a class that...Ch. 8 - Bin Manager Class Design and write an object...Ch. 8 - Tic-Tac-Toe Game Write a modular program that...Ch. 8 - Theater Ticket Sales Create a TicketManager class...
Knowledge Booster
Similar questions
- void traceMe(double x, double y) { double z; z = (pow(x, y)); cout « fixed « showpoint <« setprecision(2)<« x « ", " « y « ", " « z « endl; int main() double one=2, two=6; traceMe(two, one); 2.00 , 6,00 , 36.00 6.00 , 2.00 , 36.00 6.00 , 2,00 , 64.00 O 6.00, 2.00, 4,00arrow_forward#include <stdio.h> struct Single { int num; }; void printSingle(int f) { int binaryNum[33]; int i = 0; while(f>0) { binaryNum[i] = f % 2; f = f/2; i++; } for (int j=i-1; j>= 0; j--) { printf("%d",binaryNum[j]); } } int main() { struct Single single; single.num = 33; printf("Number: %d\n",single.num); printSingle(single.num); return 0; }arrow_forwardPLEASE HELP ME! ? Maximize and use alternative method to this code! package com.btech.pf101; import java.io.bufferedreader; import java.io.inputstreamreader; import java.util.calendar; import java.util.date; public class pawnshopcode { private static final bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); private static string name; private static int age; private static string address; private static string contactno; private static int itemtype; private static string itemtypename; private static final int itemtype_gagdet = 1; private static final int itemtype_jewelry = 2; private static final int itemtype_musicinstrument = 3; private static final int itemtype_homeequipment = 4; private static final int itemtype_landtitle = 5; private static string itemdescription; private static int periodtype; private static string periodtypename; private static final int periodtype_days = 1; private…arrow_forward
- What does the function f do? struct Point2D { double x; double y; struct Triangle { Point2D v1; Point2D v2; Point2D v3; }; void f(Triangle&t) { } int temp = 12.5; temp = t.v1.x; t.v1.x = t.v1.y; t.v1.y = temp; } int main () { Triangle mytri; mytri.v1.x = 1.0; mytri.v1.y = 22.5; f (mytri); Swaps values of x and y in vertex 1 of an argument of type Triangle Initializes value of x in vertex 1 of an argument of type Triangle Sets all x,y values in all vertices of an argument of type Triangle Swaps value of x in vertex 1 with value of x in vertex 2, for an argument of typearrow_forwardEnglish (e what is the output of the following program? #include int test (int &, int); main () { int a=10, b=15; test (b, a); test (a,b); cout<arrow_forwardIn the C programming language, if all function prototypes are listed at the top of your code, outside and above all functions, you do not need to worry about the order of the function definitions within the code. True Falsearrow_forwardCan you answer it based on the code below: #include #define MAX_EMP 5 struct Employee { int id; int age; float salary; }; int count = 0; struct Employee emp[MAX_EMP]; void display() { printf("\n---=== EMPLOYEE DATA ===---\n"); printf("EMP ID\tEMP AGE\tEMP SALARY\n"); printf("======\t=======\t==========\n"); for(int i = 0; i < count; i++) { printf("%d\t%d\t%.2f\n", emp[i].id, emp[i].age, emp[i].salary); } } void add() { if(count == MAX_EMP) { printf("\nERROR!!! Maximum Number of Employees Reached\n"); return; } printf("\nAdding Employee ===============\n"); printf("Enter Employee ID: "); scanf("%d", &emp[count].id); printf("Enter Employee Age: "); scanf("%d", &emp[count].age); printf("Enter Employee Salary: "); scanf("%f", &emp[count].salary); count++; } void update() { int id, found = 0; float newSalary; printf("\nUpdate Employee Salary…arrow_forward#include <stdio.h>#include <stdlib.h> int MAX_SIZE = 10;int n = 0; //A counter variable which will keep track of number of elements in arr. void append(int *arr, int element){ if(n == MAX_SIZE) { MAX_SIZE = MAX_SIZE * 2; int *ptr = (int*)malloc(MAX_SIZE * sizeof(int)); //Copy elements of existing array to a new array for(int i=0;i<n;i++) { ptr[i] = arr[i]; } arr = ptr; n++; } arr[n] = element;} int get(int *arr, int index){ return arr[index];}int main(){ int *arr = (int*)malloc(MAX_SIZE * sizeof(int)); n = 10; for(int i=0;i<n;i++) arr[i] = i+1; printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n); printf("\nArray: "); for(int i=0;i<n;i++) printf("%d ", arr[i]); printf("\n\nAdding an element"); append(arr, 11); printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n);…arrow_forward#include <stdio.h>#include <stdlib.h> int MAX_SIZE = 10;int n = 0; //A counter variable which will keep track of number of elements in arr. void append(int *arr, int element){ if(n == MAX_SIZE) { MAX_SIZE = MAX_SIZE * 2; int *ptr = (int*)malloc(MAX_SIZE * sizeof(int)); //Copy elements of existing array to a new array for(int i=0;i<n;i++) { ptr[i] = arr[i]; } arr = ptr; n++; } arr[n] = element;} int get(int *arr, int index){ return arr[index];}int main(){ int *arr = (int*)malloc(MAX_SIZE * sizeof(int)); n = 10; for(int i=0;i<n;i++) arr[i] = i+1; printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n); printf("\nArray: "); for(int i=0;i<n;i++) printf("%d ", arr[i]); printf("\n\nAdding an element"); append(arr, 11); printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n);…arrow_forward#include <stdio.h>#include <stdlib.h> int MAX_SIZE = 10;int n = 0; //A counter variable which will keep track of number of elements in arr. void append(int *arr, int element){ if(n == MAX_SIZE) { MAX_SIZE = MAX_SIZE * 2; int *ptr = (int*)malloc(MAX_SIZE * sizeof(int)); //Copy elements of existing array to a new array for(int i=0;i<n;i++) { ptr[i] = arr[i]; } arr = ptr; n++; } arr[n] = element;} int get(int *arr, int index){ return arr[index];}int main(){ int *arr = (int*)malloc(MAX_SIZE * sizeof(int)); n = 10; for(int i=0;i<n;i++) arr[i] = i+1; printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n); printf("\nArray: "); for(int i=0;i<n;i++) printf("%d ", arr[i]); printf("\n\nAdding an element"); append(arr, 11); printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n);…arrow_forward#include <stdio.h>#include <stdlib.h> int MAX_SIZE = 10;int n = 0; //A counter variable which will keep track of number of elements in arr. void append(int *arr, int element){ if(n == MAX_SIZE) { MAX_SIZE = MAX_SIZE * 2; int *ptr = (int*)malloc(MAX_SIZE * sizeof(int)); //Copy elements of existing array to a new array for(int i=0;i<n;i++) { ptr[i] = arr[i]; } arr = ptr; n++; } arr[n] = element;} int get(int *arr, int index){ return arr[index];}int main(){ int *arr = (int*)malloc(MAX_SIZE * sizeof(int)); n = 10; for(int i=0;i<n;i++) arr[i] = i+1; printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n); printf("\nArray: "); for(int i=0;i<n;i++) printf("%d ", arr[i]); printf("\n\nAdding an element"); append(arr, 11); printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n);…arrow_forward2- Let a = [123; 2 3 4; 12 5], b = [ 2133 points ; 50 -2; 2 3 -1] prod = a* b. What is the value of prod?arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education